<!--
 * @页面名称: 动态窗体模型
 * @描述: 主页面
 * @修改: 
 * @Date: 
 -->
<template>
  <div class="main-box">
    <splitpanes :dbl-click-splitter="false" class="default-theme">
      <pane size="15">
        <div class="card tree">
          <left-tree ref="leftTree" @onClick="onTreeClick" @noClassManage="noClassManage" @recycle="recycle"></left-tree>
        </div>
      </pane>
      <pane size="85">
        <div class="table-box">
          <splitpanes
            horizontal
            :dbl-click-splitter="false"
            :class="`default-theme ${tableSearch ? 'table-content' : '.table-default'}`"
          >
            <!-- 父级表格 -->
            <pane>
              <div class="card table-main">
                <div class="tableWraper" :style="{ height: '100%' }">
                  <!-- 眼睛icon -->
                  <div class="showIcon" v-show="topBarShow">
                    <el-button :icon="tableSearch ? 'View' : 'Hide'" circle @click="trigger" />
                  </div>
                  <!-- 表格 -->
                  <TableBar
                    ref="tabbarRef"
                    columnType="folder"
                    :name="'tabbarRef'"
                    :father="{}"
                    :tableSearch="tableSearch"
                    :fmtData="FMTData"
                    :childs="childTabbarRef"
                    :columns="tableSetting.columns"
                    :loading="tableSetting.loading"
                    :childData="childData"
                    :paginationShow="dynamicStore.isShowPage"
                    :hasTableData="dynamicStore.tableData.length > 0"
                    :tableMenu="tableSetting.tableMenu"
                    :toolbarConfig="tableSetting.toolbarConfig"
                    @trigger="trigger"
                    @rowClick="rowClick"
                    @rowdblClick="rowdblClick"
                    @selectChange="tableSelect"
                    @pageNext="pageNext"
                    @pageAll="pageAll"
                    @viewFullText="viewFullText"
                    @toSublevel="toSublevel"
                    @menuClick="menuClick"
                    @showMetaData="showFolderMetaData"
                    @refresh="tableRefresh"
                    @showFourAspectRecords="showFourAspectRecords"
                  >
                    <template #toolbarButtons>
                      <TopBar
                        v-if="topBarShow"
                        type="parentButton"
                        :reportData="reportData"
                        @buttonClick="buttonClick"
                        @exportExcel="exportExcel"
                        @reportExcel="reportExcel"
                        @trigger="trigger"
                      ></TopBar>
                      <el-space v-if="recycleStatus">
                        <el-button @click="restore" :disabled="recycleBtnStatus[0]">还原</el-button>
                        <el-button type="danger" @click="recycleDel" :disabled="recycleBtnStatus[1]">删除</el-button>
                      </el-space>
                    </template>
                  </TableBar>
                </div>
              </div>
            </pane>
            <!-- 子级表格 -->
            <pane v-if="globalStore.showChild && childData.length > 0">
              <el-tabs v-model="activeName" class="demo-tabs" style="height: 100%" @tab-change="tabChange">
                <el-tab-pane
                  style="height: calc(100% - 40px)"
                  v-for="(item, index) in childData"
                  :key="index"
                  :label="item.FMT_Name"
                >
                  <div class="card table-main">
                    <div style="height: 100%">
                      <TableBar
                        ref="childTabbarRef"
                        columnType="file"
                        :name="'childTabbarRef'"
                        :fmtData="FMTData"
                        :father="tabbarRef"
                        :childData="childTableSetting.childDataByChildTable"
                        :columns="childTableSetting.childColumns"
                        :loading="childTableSetting.childLoading"
                        :tableMenu="childTableSetting.tableMenu"
                        :toolbarConfig="childTableSetting.toolbarConfig"
                        @rowClick="childRowClick"
                        @rowdblClick="childRowdblClick"
                        @selectChange="childTableSelect"
                        @viewFullText="childViewFullText"
                        @toSublevel="childToSublevel"
                        @showMetaData="showFileMetaData"
                        @menuClick="menuClick"
                        @showFourAspectRecords="showFourAspectRecords"
                        @refresh="getChildTableData"
                      >
                        <template #toolbarButtons>
                          <TopBar
                            v-if="childTableSetting.childTopBarShow"
                            type="childButton"
                            :reportData="childReportData"
                            @buttonClick="childButtonClick"
                            @exportExcel="exportExcel"
                            @reportExcel="childReportExcel"
                          ></TopBar>
                        </template>
                      </TableBar>
                    </div>
                  </div>
                </el-tab-pane>
              </el-tabs>
            </pane>
          </splitpanes>
        </div>
      </pane>
    </splitpanes>
    <!-- 动态表单弹出框(主业务) -->
    <dynamic-form ref="dynamicForm" :dynamicModal="dynamicModal" :self="self"></dynamic-form>
    <!-- SingalrModal弹框/在此页面用于展示删除数据的详情进度 -->
    <SingalrModal
      v-model:visible="singalrModal.visible"
      :discontinueFont="singalrModal.discontinueFont"
      @cease="cease"
      @cancel="cancel"
      width="50vw"
    >
      <div style="margin-bottom: 20px; text-align: center">
        <el-text type="primary">"{{ singalrModal.text }}"</el-text>
      </div>
      <el-progress :text-inside="true" :stroke-width="20" :percentage="singalrModal.percent" status="success" />
    </SingalrModal>
    <!-- 查看全文抽屉 -->
    <el-drawer v-model="drawerSetting.visible" :title="drawerSetting.title" :show-close="true" size="65%" direction="btt">
      <FullText ref="fulltextRef"></FullText>
    </el-drawer>
    <!-- 元数据抽屉 -->
    <el-drawer v-model="metaDataSetting.visible" title="元数据" direction="rtl" :show-close="true" size="75%">
      <MetaData ref="metaDataRef"></MetaData>
    </el-drawer>
    <!-- 目录二维码弹出框 -->
    <QRCode1 ref="QRCode1"></QRCode1>
    <!-- 数据二维码弹出框 -->
    <QRCode2 ref="QRCode2"></QRCode2>
    <!-- 修改分类 -->
    <SortModal
      ref="SortModalRef"
      :type="dynamicModal.type"
      :fmtObj="childData.filter((v: any) => v.FMT_ID)"
      :activeName="activeName"
    ></SortModal>
    <!-- 移交下一环节 -->
    <HandOverModal ref="HandOverModalRef" :handoverSetting="handoverSetting"></HandOverModal>
    <!-- 批量挂接全文 -->
    <input ref="uploadZip" accept=".zip" type="file" @change="uploadZipFile" style="display: none" />
    <!-- 全文批量挂接modal -->
    <el-dialog draggable v-model="uploadConfig.visible" title="批量挂接全文" width="500px">
      <span>是否覆盖:</span>
      <el-checkbox v-model="uploadConfig.isCover"></el-checkbox>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="uploadConfig.visible = false">取消</el-button>
          <el-button type="primary" @click="fulltextUploadMany">确定</el-button>
        </span>
      </template>
    </el-dialog>
    <!-- 轨迹查看 -->
    <Trail ref="TrailRef" :config="TrailConfig"></Trail>
    <!-- 权限管理 -->
    <AuthorityManage :config="AuthConfig"></AuthorityManage>
    <!-- 文件上传进度条 -->
    <el-dialog
      title="正在上传文件...请稍等"
      v-model="fulltextModal.isShow"
      width="30%"
      class="progress-modal"
      top="300px"
      center
      :close-on-click-modal="false"
      :showClose="false"
    >
      <template #footer>
        <span class="dialog-footer">
          <el-progress :text-inside="true" :stroke-width="20" :percentage="fulltextModal.percent" status="success" />
        </span>
      </template>
    </el-dialog>
    <!-- 离线挂载 -->
    <modal v-model:visible="mountSetting.visible" :title="mountSetting.title" width="650" @ok="mountHandle">
      <el-form :model="formData" ref="mountForm" :rules="mountRule" label-width="120px">
        <el-form-item label="挂载地址" prop="path">
          <el-input v-model="formData.path" placeholder="请输入离线挂载路径,如/GJTEST/" />
        </el-form-item>
        <el-form-item label="是否覆盖" prop="isCover">
          <el-checkbox v-model="formData.isCover" />
        </el-form-item>
        <el-form-item label="采用顺序号挂接" prop="IsOrder">
          <el-checkbox v-model="formData.isOrder" />
        </el-form-item>
      </el-form>
    </modal>
    <!-- 粘贴剪贴弹框 -->
    <modal class="pasteModal" v-model:visible="pasteSetting.visible" :title="pasteSetting.title" width="500" @ok="pasteHandle">
      <el-form :model="pasteFormData" ref="pasteForm">
        <el-form-item>
          <el-checkbox v-model="pasteFormData.isTrue">粘贴全文数据</el-checkbox>
        </el-form-item>
      </el-form>
    </modal>
    <!-- 重置流水号弹框 -->
    <modal v-model:visible="resetLSH.visible" :title="resetLSH.title" width="500" @ok="resetLSHHandle">
      <el-form :model="resetLSHFormData" :rules="LHSRule" ref="resetLHSRef">
        <el-form-item label="起始流水号" prop="lsh_start">
          <el-input v-model.number="resetLSHFormData.lsh_start"></el-input>
        </el-form-item>
      </el-form>
    </modal>
    <!-- 流水号移至 -->
    <modal v-model:visible="LSHMoveSetting.visible" :title="LSHMoveSetting.title" width="500" @ok="LSHMoveHandle">
      <el-form :model="LSHMoveFormData">
        <el-form-item label="移至流水号">
          <el-input v-model="LSHMoveFormData.moveOrder"></el-input>
        </el-form-item>
      </el-form>
    </modal>
    <!-- 标记备注弹框 -->
    <modal v-model:visible="remarkSetting.visible" :title="remarkSetting.title" width="500" @ok="remarkHandle">
      <el-form :model="remarkFormData" ref="remarkForm">
        <el-form-item label="取消标注：">
          <el-checkbox @change="remarkChange" v-model="remarkFormData.remark" />
        </el-form-item>
        <el-form-item label="标注内容：">
          <el-input v-model="remarkFormData.content" />
        </el-form-item>
        <el-form-item label="标注颜色：">
          <el-color-picker v-model="remarkFormData.color" />
        </el-form-item>
      </el-form>
    </modal>
    <!-- 数据查重弹框 -->
    <modal v-model:visible="dataCheckSetting.visible" :title="dataCheckSetting.title" width="500" @ok="dataCheckHandle">
      <el-form :model="dataCheckFormData" ref="dataCheckForm" :rules="dataCheckRule">
        <el-form-item label="选择查询字段:" prop="field">
          <!-- <el-input v-model="dataCheckFormData.field" /> -->
          <el-select v-model="dataCheckFormData.field" multiple clearable style="width: 100%">
            <el-option
              v-for="item in dataCheckSetting.type === 'folder' ? tableSetting.columns : childTableSetting.childColumns"
              :key="item.DDM_ID"
              :value="item.Field_Name"
              :label="item.DDM_CNName + '(' + item.Field_Name + ')'"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </modal>
    <!-- 查找替换 -->
    <Replacement ref="replaceModal" :config="ReplacementConfig"></Replacement>
    <!-- 拆卷 -->
    <modal v-model:visible="dismantleSetting.visible" :title="dismantleSetting.title" width="500" @ok="dismantleHandle">
      <el-checkbox v-model="dismantleSetting.isTrue">是否清除分类</el-checkbox>
    </modal>
    <!-- 查询归卷 -->
    <modal
      class="queryTheVolume_dialog"
      v-model:visible="queryTheVolumeSetting.visible"
      :title="queryTheVolumeSetting.title"
      width="80%"
      @ok="queryTheVolumeHandle"
    >
      <el-select
        @change="queryTheVolumeSelectChange"
        v-model="queryTheVolumeSelect"
        placeholder="请选择归卷数据表"
        style="width: 280px; margin-left: 8px"
      >
        <el-option
          v-for="item in FMTData.filter((v: any) => v.FMT_Parent_ID === tableSetting.rowClickObj.FMT_ID)"
          :key="item.FMT_ID"
          :label="item.FMT_Name"
          :value="item.FMT_ID"
        />
      </el-select>
      <el-input
        style="width: 450px; margin-bottom: 5px; margin-left: 24px"
        v-model="queryTheVolumeInput"
        @input="queryTheVolumeInputChange"
        placeholder="请输入查询条件"
      ></el-input>
      <div class="queryTheVolume_content">
        <div class="queryTheVolume_content_left">
          <QueryTheVolumnLeftTree @onClick="onQueryTheVolumeTreeClick" @noClassManage="noQueryTheVolumeTreeClassMana">
          </QueryTheVolumnLeftTree>
        </div>
        <div class="queryTheVolume_content_right">
          <Stable
            :columns="queryTheVolumeTableSetting.columns"
            :data="queryTheVolumeTableSetting.data"
            @selectionChange="queryTheVolumeTableSelect"
          ></Stable>
        </div>
      </div>
    </modal>
    <!-- 流水号操作弹框 -->
    <modal class="LSH_dialog" v-model:visible="LSHSetting.visible" :title="LSHSetting.title" width="60%" @ok="LSHandle">
      <el-space style="margin-bottom: 10px">
        <el-button :loading="LSHSetting.btnLoading" @click="resetLSHEvent">重置流水号</el-button>
        <el-button :loading="LSHSetting.btnLoading2" @click="sortUpLSH(LSHSetting.LShTableIndex)">流水号上移</el-button>
        <el-button :loading="LSHSetting.btnLoading3" @click="sortDownLSH(LSHSetting.LShTableIndex)">流水号下移</el-button>
        <el-button :loading="LSHSetting.btnLoading4" @click="LSHTo()">流水号移至</el-button>
        <el-input placeholder="请输入起始流水号" v-model="LSHSetting.startLSH"></el-input>
        <el-input placeholder="请输入要移至的流水号" v-model="LSHSetting.endLSH"></el-input>
      </el-space>
      <div class="LSH_content" style="height: calc(100% - 42px)">
        <Stable
          ref="lshTable"
          :columns="LSHSetting.columns"
          :data="LSHSetting.data"
          :loading="LSHSetting.loading"
          :loadingText="LSHSetting.loadingText"
          @rowClick="LSHRowClick"
        ></Stable>
      </div>
    </modal>
    <!-- 搜索弹框 -->
    <el-dialog v-model="searchSetting.visible" :title="searchSetting.title" width="40%" draggable overflow>
      <!-- <div class="btns"></div> -->
      <el-form class="search-wrap" :inline="true" :model="formModel" ref="formRef">
        <el-row>
          <el-col v-for="item in searchFieldData" :key="item.DDM_ID" :span="24">
            <el-form-item style="width: 100%" :prop="item.Field_Name" :label="item.DDM_CNName + ':'" label-width="75px">
              <!-- 部门 -->
              <el-tree-select
                v-if="item.Field_Name === 'Dept_ID'"
                style="width: 100%"
                check-strictly
                clearable
                v-model="formModel[item.Field_Name]"
                node-key="DDL_ID"
                :props="{ label: 'DDL_Name', children: 'children' }"
                :data="transTree(dictionary.Dept_ID, 'DDL_ID', 'DDL_FatherID')"
                :render-after-expand="false"
              />
              <!-- 分类 -->
              <el-tree-select
                v-else-if="item.Field_Name === 'Catalog_ID'"
                style="width: 100%"
                check-strictly
                clearable
                v-model="formModel[item.Field_Name]"
                node-key="Catalog_ID"
                :props="{ label: 'Catalog_Name', children: 'children' }"
                :data="transTree(catalogList, 'Catalog_ID', 'Catalog_Father')"
                :render-after-expand="false"
              />
              <!-- 保管期限 -->
              <el-select
                v-else-if="item.Field_Name === 'RetentionPeriod'"
                v-model="formModel[item.Field_Name]"
                clearable
                style="width: 100%"
              >
                <el-option v-for="item in dictionary.BGQXdata" :key="item.DDL_ID" :label="item.DDL_Name" :value="item.DDL_ID">
                </el-option>
              </el-select>
              <!-- 责任者 -->
              <s-input
                v-else-if="item.Field_Name === 'Responsibility'"
                v-model:value="formModel[item.Field_Name]"
                :data="dictionary.ResponsiblePerson"
                labels="DDL_Name"
                values="DDL_Name"
              >
              </s-input>
              <!-- 是否锁住 -->
              <el-checkbox v-else-if="item.Field_Name === 'IsLock'" v-model="formModel[item.Field_Name]" />
              <el-input v-else v-model="formModel[item.Field_Name]" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item style="width: 100%" prop="FuzzyQuery" label="模糊查询:" label-width="80px">
              <el-checkbox v-model="formModel.FuzzyQuery" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <div class="btns">
              <el-button type="primary" icon="Search" @click="search">搜索</el-button>
              <el-button icon="Delete" @click="reset(formRef)">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
      <!-- <template #footer>
        <span class="dialog-footer">
          <el-button type="primary" @click="searchHandle">关闭</el-button>
        </span>
      </template> -->
    </el-dialog>
    <!-- 四性检测 -->
    <!-- <el-dialog v-model="fourAspectShow" width="800" :close-on-click-modal="false" draggable> -->
    <FourAspect
      ref="fourAspectRef"
      v-if="fourAspectShow"
      :fourAspectConfigs="fourAspectConfigs"
      :fourAspectRow="fourAspectRow"
      :curFourAspectItem="curFourAspectItem"
      :allFinish="allFinish"
      :activeIndex="activeIndex"
      :selectedCount="tableSetting.selectData.length + childTableSetting.selectData.length"
      @startCheck="seletedDataHandle"
      @stopCheck="stopCheckHandle"
      @closeModal="fourAspectShow = false"
    />
    <!-- </el-dialog> -->
    <!-- 四性检测记录展示 -->
    <el-drawer v-model="isShowFourAspectRecords" title="四性检测记录" direction="btt" size="60%">
      <FourAspectRecords v-if="isShowFourAspectRecords" :fourAspectRecordsClickRow="fourAspectRecordsClickRow" />
    </el-drawer>
    <!-- url借阅 -->
    <UrlBorrow ref="UrlBorrowRef" v-model:visible="urlModal.isShow" width="80%" @ok="urlBorrow"> </UrlBorrow>
  </div>
</template>

<script lang="tsx">
import {
  reactive,
  onMounted,
  ref,
  getCurrentInstance,
  nextTick,
  defineComponent,
  watch,
  computed,
  onActivated,
  onDeactivated
} from "vue";
import type { FormInstance } from "element-plus";
import UrlBorrow from "../../../components/UrlBorrow/index.vue";
import DynamicForm from "./DynamicForm.vue";
import LeftTree from "./components/LeftTree/LeftTree.vue";
import TableBar from "./components/TableBar/index.vue";
import TopBar from "./components/TopBar/index.vue";
import FullText from "./components/FullText/FullText.vue";
import QRCode1 from "./components/QRCode/QRCode1.vue";
import QRCode2 from "./components/QRCode/QRCode2.vue";
import AuthorityManage from "./components/AuthorityManage/index.vue";
import { SortModal } from "./components";
import HandOverModal from "./components/handoverModal/index.vue";
import Replacement from "./components/Replacement/index.vue";
import MetaData from "./components/metaData/index.vue";
import Trail from "./components/trail/index.vue";
import QueryTheVolumnLeftTree from "./components/LeftTree/QueryTheVolumeLeftTree.vue";
import Stable from "@/components/Stable/index.vue";
import { useRouter, useRoute } from "vue-router";
import { ButtonClick } from "./events";
import { useDynamicStore } from "@/stores/modules/dynamic";
import { useDictionryStore } from "@/stores/modules/dictionary";
import { useUserStore } from "@/stores/modules/user";
import { useGlobalStore } from "@/stores/modules/global";
import { useCatalogStore } from "@/stores/modules/catalog";
import { useAppStore } from "@/stores/modules/app";
import { defaultVisibleColumn } from "./ts/columnData";
import { Splitpanes, Pane } from "splitpanes";
import "splitpanes/dist/splitpanes.css";
import { transTree } from "@/utils/util";
import { ButtonStatus } from "./components/TopBar/InitButton";
import { Excel } from "@/utils/reportUpload2";
import RuleClass from "./ts/FieldRule";
import { useFormatter } from "@/hooks/useFormatter";
import ACrypto from "@/utils/crypto";
import { cloneDeep, isEqual } from "lodash-es";
import useCurrentInstance from "@/utils/useCurrentInstance";
import { columnCoverter } from "@/views/system/dynamicMain/ts/until";
import FourAspect from "./components/FourAspect/index.vue";
import FourAspectRecords from "./components/FourAspect/FourAspectRecords.vue";

export default defineComponent({
  components: {
    FullText,
    DynamicForm,
    LeftTree,
    TableBar,
    TopBar,
    QRCode1,
    QRCode2,
    SortModal,
    HandOverModal,
    Splitpanes,
    Pane,
    Trail,
    AuthorityManage,
    Replacement,
    MetaData,
    QueryTheVolumnLeftTree,
    Stable,
    FourAspect,
    FourAspectRecords,
    UrlBorrow
  },
  setup() {
    // 表格字段转换
    const formatter = ({ row, column, cellValue }: any): any => {
      const catalogList = catalogStore.catalogList;
      let ruleList = [];
      ruleList = dynamicStore.childVisibleConfig.FieldRule.filter((v: any) => v.FR_RuleType === "display");
      const tempObj = ruleList.find((v: any) => v.FR_TableField === column.property);
      let result = null;
      let param = null;

      if (tempObj) {
        // 字典转换
        param = tempObj.FR_Rule.split(":")[1];
        if (tempObj.FR_Rule.includes("dictionary:")) {
          result = columnCoverter(tempObj.FR_Rule, cellValue);
        } else if (tempObj.FR_Rule.toLowerCase().includes("datetime:")) {
          // 时间转换
          result = dtime(row[tempObj.FR_TableField]).format(param);
        } else if (tempObj.FR_Rule.toLowerCase().includes("userinfo:")) {
          // 人员的id转换
          const temp = userStore.getUserList.find((v: any) => v.U_ID === cellValue);
          result = temp ? temp[param] : "";
        } else if (tempObj.FR_Rule.toLowerCase().includes("catalogconvert:")) {
          // 分类id转换
          const temp = catalogList.find((v: any) => v.Catalog_ID && v.Catalog_ID === cellValue);
          console.log(temp, param);
          result = temp ? temp[param] : "";
        } else if (tempObj.FR_Rule.toLowerCase().includes("orgconvert:")) {
          const temp = catalogList.find(v => v[tempObj.Field_Name] === cellValue);
          result = temp ? temp[param] : "";
        } else if (tempObj.FR_Rule.toLowerCase().includes("jm")) {
          // 对加密字段转换
          result = ACrypto.getSS(row[tempObj.FR_TableField]);
        } else if (tempObj.FR_Rule.toLowerCase().includes("tozh")) {
          if (row[tempObj.FR_TableField]) {
            result = "是";
          } else {
            result = "否";
          }
        }
      }
      if (result) {
        return result;
      }
      return cellValue;
    };
    // 头部按钮是否显示
    const topBarShow = ref(false);
    // 头部按钮高度
    const headerHeight = ref(0);
    // 表格高度
    const tableHeight = ref(100);
    // 动态计算表格高度
    const sumHeight = computed(() => {
      return `calc(${tableHeight.value}% - ${headerHeight.value}px)`;
    });
    // 子级头部按钮高度
    const childHeaderHeight = ref(0);
    // 子级表格高度
    const childTableHeight = ref(100);
    // 子级表格高度
    const childHeight = computed(() => {
      return `calc(${childTableHeight.value}% - ${childHeaderHeight.value}px)`;
    });
    // 按钮状态实例
    const buttonStatus = new ButtonStatus();
    const { proxy } = getCurrentInstance() as any;
    // pinia数据
    const dictionryStore = useDictionryStore();
    const globalStore = useGlobalStore();
    const userStore = useUserStore();
    const catalogStore = useCatalogStore();
    const appStore = useAppStore();
    // 字典数据
    const dictionary = dictionryStore.getDictionaryObj;
    // 搜索功能分类数据
    const catalogList = ref([]);
    // 搜索字段
    const searchFieldData = ref<any>([]);
    // 顶部搜索表单绑定字段
    const formModel: any = reactive({
      FuzzyQuery: true
    });
    // 表单实例
    const formRef = ref<FormInstance>();
    // 搜索是否显示
    const tableSearch = ref(false);
    // 目录二维码弹框实例
    const QRCode1 = ref();
    // 数据二维码弹框实例
    const QRCode2 = ref();
    // 修改分类弹出框
    const SortModalRef = ref();
    // 轨迹查看弹出框
    const TrailRef = ref();
    // 轨迹查看弹框配置
    const TrailConfig = reactive({
      // 轨迹查看弹框是否显示
      visible: false,
      // 轨迹查看弹框标题
      title: "",
      // 轨迹查看弹框数据
      data: {} as any
    });
    // 权限管理配置
    const AuthConfig = reactive({
      visible: false,
      title: "",
      type: 1
    });
    // 获取路由
    const router = useRouter();
    const route = useRoute();
    // 路由携带的参数
    const routeData = ref(route.query as any);
    // 父级对象
    const fatherObj = routeData.value.fatherObj ? JSON.parse(decodeURIComponent(routeData.value.fatherObj as any)) : undefined;
    // 获取pinia数据
    const dynamicStore = useDynamicStore();
    // 当前组件实例
    const self = ref();
    // 获取全文组件实例
    const fulltextRef = ref();
    // 获取元数据实例
    const metaDataRef = ref();
    //表格实例
    const tabbarRef = ref();
    // 左侧树实例
    const leftTree = ref();
    // 子级数据集合
    const childData: any = ref([]);
    // 左侧树点击保存对象
    const leftTreeObj = ref();
    // 获取到所有的表数据
    const FMTData = ref([]);

    // 四性检测弹框是否显示
    const fourAspectShow = ref<boolean>(false);
    // 是否展示四性检测记录
    const isShowFourAspectRecords = ref<boolean>(false);
    // 四性检测配置列表
    const fourAspectConfigs = ref<any[]>([]);
    // 四性检测点击行
    const fourAspectRow = ref<any>({});
    // 四性按钮点击查看记录
    const fourAspectRecordsClickRow = ref<any>({});
    // 四性检测dom
    const fourAspectRef = ref<any>({});
    // 当前四性检测的行
    const curFourAspectItem = ref<any>({});
    // 全部检测是否已经结束
    const allFinish = ref<boolean>(false);
    // 折叠面板活跃下标
    const activeIndex = ref<number>(1);
    // 是否停止检测
    const stopCheck = ref<boolean>(false);

    // 表格配置
    const tableSetting = reactive({
      columns: defaultVisibleColumn as any[],
      rowClickObj: null as any, //点击保存行数据
      loading: false, //加载图标是否显示
      canClickNext: true, //下一页标识
      selectData: [] as any[],
      // 主表右键配置项
      tableMenu: {
        enabled: true,
        className: "my-menus",
        body: {
          options: [
            [
              { code: "dataInfo", name: "加入外链清单", prefixIcon: "DocumentAdd", className: "my-copy-item" },
              { code: "scanning", name: "四性检测" }
            ]
          ]
        }
      },
      // 工具栏配置
      toolbarConfig: {
        refresh: false as boolean | object,
        import: false as boolean | object,
        export: false as boolean | object,
        print: false as boolean | object,
        zoom: false as boolean | object,
        custom: false as boolean | object,
        slots: {
          buttons: "toolbarButtons"
        },
        enabled: true
      }
    });
    // 抽屉配置
    const drawerSetting = reactive({
      visible: false,
      title: ""
    });
    // 元数据弹框设置
    const metaDataSetting = reactive({
      visible: false
    });
    // 动态窗体配置
    const dynamicModal = reactive({
      title: "",
      htmlCode: "",
      type: "",
      formType: 1
    });
    // 移交下一环节配置
    const handoverSetting = reactive({
      visible: false, //是否显示窗体
      title: "", //窗体的标题
      data: [], //要提交的数据
      type: "", //标识是父级还是子级
      StatusValue: 1, // 流程状态
      openStatus: false // 数据是否是开放状态
    });
    // 移交下一环节弹框实例
    const HandOverModalRef = ref();
    // 批量挂接全文上传框实例
    const uploadZip = ref();
    // 全文批量挂接
    const uploadConfig = ref({
      visible: false,
      isCover: false
    });
    // 上传文件进度条配置
    const fulltextModal = reactive({
      isShow: false,
      percent: 0
    });
    // 监听当前页面状态
    const activatedFlag = ref(false);
    // 子级表格配置
    const childTableSetting = reactive({
      childTableData: [] as any[],
      // 子级表格头部按钮是否显示
      childTopBarShow: false,
      // 子级表格表头数据
      childColumns: defaultVisibleColumn as any[],
      // 子级表格加载状态
      childLoading: false,
      // 点击保存行数据
      rowClickObj: {} as any,
      // 选中数据
      selectData: [] as any[],
      // 子级表格下的子页面数据
      childDataByChildTable: [] as any[],
      // 子表右键配置项
      tableMenu: {
        enabled: true,
        className: "my-menus",
        body: {
          options: [
            [
              { code: "dataInfo", name: "加入外链清单", prefixIcon: "DocumentAdd", className: "my-copy-item" },
              { code: "scanning", name: "四性检测" }
            ]
          ]
        }
      },
      // 工具栏配置
      toolbarConfig: {
        refresh: false as boolean | object,
        import: false as boolean | object,
        export: false as boolean | object,
        print: false as boolean | object,
        zoom: false as boolean | object,
        custom: false as boolean | object,
        slots: {
          buttons: "toolbarButtons"
        },
        enabled: true
      }
    });
    // 子级表格实例
    const childTabbarRef = ref();
    // tab页标识
    const activeName = ref("0");
    // 主表报表数据
    const reportData = ref<any[]>([]);
    // 子表报表数据
    const childReportData = ref<any[]>([]);
    // 离线挂接配置
    const mountSetting = reactive({
      visible: false,
      title: "离线挂接"
    });
    // 离线挂接表单绑定字段
    const formData = reactive({
      path: "",
      isCover: false,
      isOrder: true
    });
    // 离线挂接表单实例
    const mountForm = ref();
    // 离线挂载表单规则
    const mountRule = reactive({
      path: [{ required: true, message: "请填写路径", trigger: "change" }]
    });
    // 挂载配置
    const mountConfig = reactive({
      type: "folder"
    });
    // 粘贴配置
    const pasteSetting = reactive({
      visible: false,
      title: "选择粘贴参数",
      type: "",
      is_Copy: true
    });
    // 粘贴剪切表单绑定字段
    const pasteFormData = reactive({
      isTrue: true
    });
    // 删除弹框配置
    const singalrModal = reactive({
      visible: false, //弹框状态
      discontinueFont: "中止", // 弹框按钮文字
      discontinueStatus: false, // 弹框按钮状态
      networkStatus: true, // 单个网络状态
      AllNetworkStatus: true, // 所有的网络状态
      circulatingIndex: 0, // 循环索引
      percent: 0, // 进度条进度
      text: "" // 提示文字
    });
    // 重置流水号配置
    const resetLSH = reactive({
      visible: false,
      title: "重置流水号",
      type: 1
    });
    // 重置流水号表单绑定字段
    const resetLSHFormData = reactive({
      lsh_start: 1
    });
    // 重置流水号规则
    const LHSRule = reactive({
      lsh_start: [{ required: true, message: "请填写起始流水号", trigger: "blur" }]
    });
    // 流水号移至配置
    const LSHMoveSetting = reactive({
      visible: false,
      title: "流水号移至",
      type: ""
    });
    // 流水号移至表单绑定字段
    const LSHMoveFormData = ref({
      moveOrder: "1"
    });
    // 流水号表单实例
    const resetLHSRef = ref();
    // 标记备注弹框配置
    const remarkSetting = reactive({
      visible: false,
      title: "标记备注",
      type: ""
    });
    // 标记备注表单绑定字段
    const remarkFormData = reactive({
      remark: false,
      content: "",
      color: ""
    });
    // 标记备注表单实例
    const remarkForm = ref();
    // 数据查重弹框配置
    const dataCheckSetting = reactive({
      visible: false,
      title: "数据查重",
      type: ""
    });
    // 数据查重表单绑定字段
    const dataCheckFormData = reactive({
      field: []
    });
    // 数据查重表单实例
    const dataCheckForm = ref();
    // 数据查重表单规则
    const dataCheckRule = reactive({
      field: [{ required: true, message: "请选择字段", trigger: "change" }]
    });
    // 查找替换配置
    const ReplacementConfig = reactive({
      type: 1 // 用于区分是主表还是子表（1主表2子表）
    });
    // 查找替换弹框实例
    const replaceModal = ref();
    // 拆卷
    const dismantleSetting = reactive({
      visible: false,
      title: "拆卷",
      isTrue: false,
      type: "folder"
    });
    // 查询归卷
    const queryTheVolumeSetting = reactive({
      visible: false,
      title: "查询归卷"
    });
    // 查询归卷数据表绑定字段
    const queryTheVolumeSelect = ref("");
    // 查询归卷表格配置
    const queryTheVolumeTableSetting = reactive({
      columns: [
        { type: "checkbox", width: 55 },
        {
          title: "序号",
          field: "SmallOrder",
          width: 80
        },
        { title: "年度", field: "Year", sortable: true, width: 120 },
        {
          title: "题名",
          field: "Title",
          sortable: true,
          formatter: formatter
        },
        {
          title: "责任者",
          field: "Responsibility",
          sortable: true,
          width: 120,
          formatter: formatter
        },
        {
          title: "保管期限",
          field: "RetentionPeriod",
          sortable: true,
          width: 120,
          formatter: formatter
        }
      ],
      data: [],
      sourceData: [],
      selectData: []
    });
    // 查询归卷搜索字段
    const queryTheVolumeInput = ref("");
    // 查询归卷子表规则
    const queryTheVolumeRule = ref({});
    // 表格单击索引
    const tableIndex = ref(0);
    // 流水号操作弹框配置
    const LSHSetting = reactive({
      visible: false,
      title: "大流水号操作",
      columns: [
        { title: "新流水号", type: "seq", width: 120 },
        { title: "原大流水号", field: "Order", width: 120, sortable: true },
        { title: "原小流水号", field: "SmallOrder", width: 120, sortable: true },
        { title: "档号", field: "Code", width: 180, sortable: true },
        {
          title: "题名",
          field: "Title",
          sortable: true,
          formatter: ({ row, column, cellValue }) => {
            return ACrypto.getSS(cellValue);
          }
        }
      ],
      data: [],
      startLSH: 1,
      endLSH: null,
      // 加载字体
      loadingText: "正在加载中...",
      loading: false,
      // 流水号弹框表格点击数据行索引
      LShTableIndex: 0,
      // 流水号弹框表格点击数据
      rowClickObj: null,
      // 按钮加载事件
      btnLoading: false,
      btnLoading2: false,
      btnLoading3: false,
      btnLoading4: false,
      // 1代表主表2代表子表
      type: 1,
      ruleList: [],
      tableName: "",
      orderType: "Order"
    });
    // 流水号表格实例
    const lshTable = ref();
    // 子表按钮集合
    const childBottonList = ref<any[]>([]);
    // 搜索弹框配置
    const searchSetting = reactive({
      visible: false,
      title: "搜索"
    });
    // 回收站按钮是否显示
    const recycleStatus = ref(false);
    // url借阅弹框配置
    const urlModal = reactive({
      isShow: false
    });
    // url借阅弹框实例
    const UrlBorrowRef = ref();
    // 回收站按钮状态
    const recycleBtnStatus = ref([true, true]);
    // 主表搜索事件
    const search = () => {
      let param: any = {};
      // 构建查询参数
      for (const key in formModel) {
        if (formModel[key]) {
          param[key] = formModel[key];
        }
      }
      const params = {
        ...param,
        PageIndex: 1,
        PageSize: dynamicStore.pageSize,
        FMT_ID: routeData.value.fmtid,
        Status: routeData.value.status,
        FuzzyQuery: formModel.FuzzyQuery
      };
      proxy.$vueAxios.post("Dynamic/Search", params).then((res: any) => {
        if (res.Mark) {
          if (res.Count < dynamicStore.pageSize) {
            dynamicStore.isShowPage = false;
          } else {
            dynamicStore.isShowPage = true;
          }
          dynamicStore.setTableData(res.List);
          dynamicStore.childTableData = [];
        } else {
          dynamicStore.isShowPage = false;
          dynamicStore.setTableData([]);
        }
      });
    };
    // 切换搜索显示和隐藏
    const trigger = () => {
      tableSearch.value = !tableSearch.value;
      searchSetting.visible = true;
    };
    // 重置
    const reset = (formEl: FormInstance | undefined) => {
      if (!formEl) return;
      formEl.resetFields();
    };
    /**
     * @description 获取搜索字段
     * @param
     * @param
     * @returns
     */
    const getSearchField = () => {
      proxy.$vueAxios
        .post(
          "Master_Base_Data_Disp_Mstr/GetConditional",
          {
            order: "DDM_Order asc",
            dtoList: [{ fieldName: "FMT_ID", fieldValue: routeData.value.fmtid }]
          },
          { noLoading: true }
        )
        .then((res: any) => {
          const str = "DDM_Enable_Query_" + routeData.value.status;
          searchFieldData.value = res.List.filter((v: any) => {
            return v[str] === true;
          });
          searchFieldData.value.forEach((item: any) => {
            Reflect.set(formModel, item.Field_Name, null);
          });
        });
    };
    // 点击树节点
    const onTreeClick = (treeNode: any) => {
      // tableSetting.toolbarConfig.enabled = true;
      tableSetting.rowClickObj = null;
      dynamicStore.childTableData = [];
      dynamicStore.childSourthTableData = [];
      tableSetting.selectData = [];
      topBarShow.value = true;
      recycleStatus.value = false;
      headerHeight.value = 42;
      const el = document.querySelector(".vxe-grid--toolbar-wrapper") as any;
      // 改变按钮状态
      leftTreeObj.value = treeNode;
      if (treeNode.PC_PermissionStr) {
        const buttonaArr = JSON.parse(treeNode.PC_PermissionStr)[0];
        if (buttonaArr.length > 0) {
          if (globalStore.assemblySize === "default") {
            el.style.height = "47px";
          } else if (globalStore.assemblySize === "large") {
            el.style.height = "57px";
          } else if (globalStore.assemblySize === "small") {
            el.style.height = "37px";
          }
        } else {
          el.style.height = "0";
        }
        if (buttonaArr.includes("导入")) {
          tableSetting.toolbarConfig.import = {
            icon: "vxe-icon-cloud-upload"
          };
        } else {
          tableSetting.toolbarConfig.import = false;
        }
        if (buttonaArr.includes("导出")) {
          tableSetting.toolbarConfig.export = {
            icon: "vxe-icon-cloud-download"
          };
        } else {
          tableSetting.toolbarConfig.export = false;
        }
        if (buttonaArr.includes("打印")) {
          tableSetting.toolbarConfig.print = {
            icon: "vxe-icon-print"
          };
        } else {
          tableSetting.toolbarConfig.print = false;
        }
        if (buttonaArr.includes("刷新")) {
          tableSetting.toolbarConfig.refresh = {
            icon: "vxe-icon-refresh",
            iconLoading: "vxe-icon-refresh roll"
          };
        } else {
          tableSetting.toolbarConfig.refresh = false;
        }
        if (buttonaArr.includes("全屏")) {
          tableSetting.toolbarConfig.zoom = {
            iconIn: "vxe-icon-fullscreen",
            iconOut: "vxe-icon-minimize"
          };
        } else {
          tableSetting.toolbarConfig.zoom = false;
        }
        if (buttonaArr.includes("自定义列")) {
          tableSetting.toolbarConfig.custom = {
            icon: "vxe-icon-menu"
          };
        } else {
          tableSetting.toolbarConfig.custom = false;
        }
      }
      dynamicStore.setPageIndex(true);
      if (dynamicStore.noCatalogStatus) {
        noClassManage();
      } else {
        getPageData();
      }
      getReportData();
      if (fatherObj) {
        dynamicStore.setChildLeftClick(true);
      } else {
        dynamicStore.setChildLeftClick(false);
      }
    };
    const signalrEvent = () => {
      proxy.signalr.off("SendTest");
      proxy.signalr.on("SendTest", (res: any) => {
        proxy.$showLoading({ tip: res });
        if (res.trim().startsWith("start")) {
          // 传输开始
          proxy.$showLoading({ tip: res });
        }
        if (res.trim().startsWith("stop")) {
          // 传输结束
          proxy.$hideLoading();
        }
      });
      proxy.signalr.off("DownloadZip");
      proxy.signalr.on("DownloadZip", (res: any) => {
        proxy.$showLoading({ tip: res });
        if (res.trim().startsWith("开始")) {
          // 传输开始
          proxy.$showLoading({ tip: res });
        }
        if (res.trim().startsWith("结束")) {
          // 传输结束
          proxy.$hideLoading();
        }
      });
      proxy.signalr.off("SendExecuteContentPage");
      proxy.signalr.on("SendExecuteContentPage", (res: any) => {
        proxy.$showLoading({ tip: "档案正在ORC中,请稍候..." });
        if (res.trim().startsWith("start")) {
          // 传输开始
          // proxy.$showLoading({ tip: res });
          proxy.$showLoading({ tip: "档案开始ORC,请稍候..." });
        }
        if (res.trim().startsWith("stop")) {
          // 传输结束
          proxy.$hideLoading();
        }
      });
    };
    /**
     * @description 获取主表报表数据
     * @param
     * @param
     * @returns
     */
    const getReportData = () => {
      proxy.$vueAxios
        .post(
          "Master_Base_ReportModule/GetConditional",
          {
            order: "RM_Index asc",
            dtoList: [{ fieldName: "FMT_ID", fieldValue: routeData.value.fmtid }]
          },
          { noLoading: true }
        )
        .then((res: any) => {
          if (res.Mark) {
            reportData.value = res.List.filter((v: any) => v.RM_Enabled).filter((v: any) =>
              JSON.parse(leftTreeObj.value.PC_PermissionStr)[2].includes(v.RM_ID)
            );
          }
        });
    };
    // 报表单击
    const reportExcel = (item: any) => {
      if (tableSetting.selectData.length == 0) {
        proxy.$message.warning("请选择数据");
        return;
      }
      if (item.RM_IsFront) {
        new Excel(
          item,
          tableSetting.selectData,
          fatherObj ? [{ ...fatherObj }] : null,
          childTableSetting.childTableData
        ).download();
      } else {
        new ButtonClick().reportModuleClickEvent(item.RM_ID, item, "folder");
      }
    };
    // 主表单击
    const rowClick = async ({ row, rowIndex }: any) => {
      tableIndex.value = rowIndex;
      // 显示子表格头部按钮
      childTableSetting.childTopBarShow = true;
      childHeaderHeight.value = 42;
      tableSetting.rowClickObj = row;
      recycleBtnStatus.value = [false, false];
      if (isEqual(row, dynamicStore.tableSelect[0])) {
        return;
      }
      tabbarRef.value.setCheckboxRow([row], true);

      tableSelect([row]);
      if (globalStore.showChild && childData.value.length > 0) {
        // 子级表格数据
        await getChildButtonPermission();
        await getChildTableData();
      }
      console.log(userStore.userInfo);
      proxy.$vueAxios.post("Master_Base_Log", {
        fonds_ID: row["Fonds_ID"],
        fM_ID: row["FM_ID"],
        fmT_ID: row["FMT_ID"],
        g_ID: 66,
        u_ID: userStore.userInfo.U_ID,
        log_ID: proxy.$global.createID(),
        log_Type: "查询",
        log_Content: JSON.stringify(userStore.userInfo.U_CName + "用户看了目录[" + row["Title"] + "]"),
        log_Time: new Date().toLocaleDateString(),
        log_IP: "",
        log_RecordID: row["Record_ID"],
        log_RecordTMTID: 0,
        log_ChangMark: "数据查看",
        log_IsHighRisk: false,
        log_Remark: ""
      });
    };
    // 主表双击
    const rowdblClick = ({ row }: any) => {
      let flag = false;
      const newPC_PermissionStr = JSON.parse(catalogStore.treeNode.PC_PermissionStr)[0];
      newPC_PermissionStr.forEach((v: any) => {
        if (v == "修改") {
          flag = true;
        }
      });
      console.log("(((((((((((((((((((())))))))))))))))))))", !userStore.userInfo.U_ReadOnly, flag, !row.IsLock);
      if (routeData.value.fatherObj) {
        if (!userStore.userInfo.U_ReadOnly && flag && !row.IsLock && ![11, 21].includes(row.Status)) {
          new ButtonClick().ParentClickEvent("修改", proxy);
        }
      } else {
        if (!userStore.userInfo.U_ReadOnly && flag && !row.IsLock && ![11, 21].includes(row.Status)) {
          new ButtonClick().ParentClickEvent("修改", proxy);
        }
      }
    };
    /**
     * @description: 主表右键单击
     */
    const menuClick = async ({ menu, row, column }: any) => {
      if (!row) {
        proxy.$message.warning("请选中数据!");
        return;
      }
      if (menu.code === "dataInfo") {
        const childFmt = FMTData.value.filter((v: any) => v.FMT_Parent_ID == row.FMT_ID);
        // 当前行下所有子表的全文
        await GetChildDataLists(childFmt, row.Record_ID);
        // 当前行全文
        await getFullTextData(row);
        urlModal.isShow = true;
        nextTick(() => {
          if (UrlBorrowRef.value) {
            UrlBorrowRef.value.open();
          }
        });
      }
      if (menu.code === "scanning") {
        console.log("row", row);
        fourAspectShow.value = true;
        allFinish.value = false; // 检测即置为扫描中
      }
    };
    const GetChildDataLists = async (ChildFmts: any, ParentID: string) => {
      for (let i = 0; i < ChildFmts.length; i++) {
        const fmt = ChildFmts[i];
        await proxy.$vueAxios
          .get(
            "Dynamic/CommonGet",
            {
              fmtid: fmt.FMT_ID,
              parentid: ParentID,
              fmid: routeData.value.fmid,
              status: routeData.value.status,
              isDelete: false,
              searchType: 2
            },
            { noLoading: true }
          )
          .then(async (res: any) => {
            for (let j = 0; j < res.List.length; j++) {
              const item = res.List[j];
              await doUrl(item);
              await GetChildDataLists(
                FMTData.value.filter((v: any) => v.FMT_Parent_ID == fmt.FMT_ID),
                item.Record_ID
              );
            }
          });
      }
    };
    const doUrl = (dataRow: any) => {
      proxy.$vueAxios
        .post(
          "Master_Base_AllInfos/GetConditional",
          {
            order: "AI_Index asc",
            dtoList: [{ fieldName: "Record_ID", fieldValue: dataRow.Record_ID }]
          },
          { noLoading: true }
        )
        .then((res: any) => {
          appStore.setBorrrowData(res.List);
        });
    };
    // 点击右键获取全文数据
    const getFullTextData = async (row: any) => {
      await proxy.$vueAxios
        .post(
          "Master_Base_AllInfos/GetConditional",
          {
            order: "AI_Index asc",
            dtoList: [{ fieldName: "Record_ID", fieldValue: row.Record_ID }]
          },
          { noLoading: true }
        )
        .then((res: any) => {
          // tableSetting.data = res.List;
          appStore.setBorrrowData(res.List);
        });
    };
    // 停止检测
    const stopCheckHandle = () => {
      stopCheck.value = true; // 停止检测
    };
    // 开始检测
    const seletedDataHandle = async () => {
      stopCheck.value = false; // 开始检测
      console.log("selectedData", tableSetting.selectData);
      const allSelectedData = [...tableSetting.selectData, ...childTableSetting.selectData];
      if (!allSelectedData.length) {
        proxy.$message.warning("请确保勾选了数据!");
        fourAspectShow.value = false;
        return;
      }
      for (let index = 0; index < allSelectedData.length; index++) {
        try {
          if (stopCheck.value) {
            proxy.$message.warning("已停止四性检测!");
            return;
          }
          const config = allSelectedData[index];
          fourAspectRow.value = config;

          const res = await proxy.$vueAxios.post("Master_Base_FourAspect_Conf/GetConditional", {
            pageIndex: 0,
            pageSize: 0,
            order: "table_id asc",
            dtoList: [
              {
                fieldName: "table_id",
                fieldValue: config.FMT_ID,
                conditionalType: 0
              }
            ]
          });

          if (res.Mark) {
            if (res.List.length) {
              fourAspectConfigs.value = res.List;

              curFourAspectItem.value = allSelectedData[index]; // 传入归档号及标题
              curFourAspectItem.value.Title = ACrypto.getSS(curFourAspectItem.value.Title);

              await new Promise(r => {
                setTimeout(() => {
                  r(1);
                }, 1000);
              });

              activeIndex.value = index + 1;
              await fourAspectRef.value?.checkHandle();
              if (stopCheck.value) {
                proxy.$message.warning("已停止四性检测!");
                return;
              }
              // 检测完毕之后提示
              if (index >= allSelectedData.length - 1) {
                allFinish.value = true; // 检测完毕
                fourAspectRef.value?.pauseTimer();
                proxy.$message.success("检测完毕！");
              }
            } else {
              fourAspectShow.value = false; // 没有配置项则关闭弹框
              proxy.$message.warning(`归档号${config.Code}未配置四性检测策略!`);
            }
          }
        } catch (error) {
          console.log(error);
        }
      }

      // proxy.$vueAxios
      //   .post("Master_Base_FourAspect_Conf/GetConditional", {
      //     pageIndex: 0,
      //     pageSize: 0,
      //     order: "table_id asc",
      //     dtoList: [
      //       {
      //         fieldName: "table_id",
      //         fieldValue: item.FMT_ID,
      //         conditionalType: 0
      //       }
      //     ]
      //   })
      //   .then((res: any) => {
      //     console.log("四性检测配置查询---", res);
      //     if (res.Mark) {
      //       if (res.List.length) {
      //         fourAspectConfigs.value = res.List;
      //         fourAspectShow.value = true;
      //       } else {
      //         proxy.$message.warning("请先导入检测配置数据!");
      //       }
      //     }
      //   });
    };
    // 主表多选
    const tableSelect = (val: any) => {
      tableSetting.selectData = val;
      dynamicStore.setTableSelect(val);
      console.log(tableSetting.selectData);

      if (tableSetting.selectData.length > 0) {
        recycleBtnStatus.value = [false, false];
      } else {
        recycleBtnStatus.value = [true, true];
      }
    };
    /**
     * @description 主表跳转子级页面
     * @param
     * @param
     * @returns
     */
    const toSublevel = async (row: any, item: any) => {
      const Res = await proxy.$vueAxios.post("Master_Base_FormModel_Table/GetConditional", {
        order: "FMT_Type ASC",
        dtoList: [
          {
            fieldName: "FM_ID",
            fieldValue: routeData.value.fmid
          }
        ]
      });
      const childrenFmtId2 = Res.List.filter((v: any) => v.FMT_Parent_ID === item.FMT_ID).map((v: any) => v.FMT_ID);
      // const stateName: any = {
      //   1: "Collect",
      //   2: "Arrangement",
      //   3: "Storage",
      //   4: "Utilization"
      // };
      router.push({
        name: "sublevel",
        query: {
          fmid: row.FM_ID,
          fmtid: item.FMT_ID,
          childrenFmtId: childrenFmtId2,
          status: routeData.value.status,
          fondsId: routeData.value.fondsId,
          code: row.Code,
          fatherObj: encodeURIComponent(JSON.stringify(row))
        }
      });
    };
    /**
     * @description 主表查看全文
     * @param
     * @param
     * @returns
     */
    const viewFullText = (row: any) => {
      drawerSetting.title = "查看全文";
      drawerSetting.visible = true;
      nextTick(() => {
        fulltextRef.value.getData(row);
      });

      buttonStatus.filterFulltextButtonAuth(JSON.parse(catalogStore.treeNode.PC_PermissionStr)[1]);
    };
    /**
     * @description 获取表格数据
     * @param
     * @param
     * @returns
     */
    const getPageData = async () => {
      if (leftTreeObj.value || routeData.value.fatherObj) {
        tableSetting.loading = true;
        dynamicStore
          .getTableData({
            fmid: routeData.value.fmid,
            fmtid: routeData.value.fmtid,
            catalogid: leftTreeObj.value ? leftTreeObj.value.Catalog_ID : null,
            status: routeData.value.status,
            searchType: leftTreeObj.value ? 1 : 2,
            pageIndex: 1,
            pageSize: dynamicStore.pageSize,
            parentid: routeData.value.fatherObj
              ? JSON.parse(decodeURIComponent(routeData.value.fatherObj as any)).Record_ID
              : undefined
          })
          .then((res: any) => {
            tableSetting.loading = false;
            dynamicStore.setTableData(res.List);
            dynamicStore.setSourthTableData(res.List);
            if (tableSetting.selectData.length > 0) {
              tableSetting.selectData.forEach(element => {
                if (dynamicStore.tableData.filter(s => s.Record_ID === element.Record_ID).length > 0) {
                  dynamicStore.tableData.filter(s => s.Record_ID === element.Record_ID)[0].checkbox = true;
                }
              });
            }
          });
        console.log("#########################");
      } else {
        dynamicStore.setTableData([]);
      }
    };
    // 无分类管理
    const noClassManage = () => {
      dynamicStore.setChildLeftClick(false);
      headerHeight.value = 42;
      const el = document.querySelector(".vxe-grid--toolbar-wrapper") as any;
      if (globalStore.assemblySize === "default") {
        el.style.height = "47px";
      } else if (globalStore.assemblySize === "large") {
        el.style.height = "57px";
      } else if (globalStore.assemblySize === "small") {
        el.style.height = "37px";
      }
      if (dynamicStore.noCatalogStatus) {
        topBarShow.value = true;
        recycleStatus.value = false;
        tableSetting.loading = true;
        dynamicStore.childTableData = [];
        dynamicStore
          .getTableData({
            fmid: routeData.value.fmid,
            fmtid: routeData.value.fmtid,
            status: routeData.value.status,
            searchType: dynamicStore.noCatalogStatus ? 1 : 2,
            pageIndex: 1,
            pageSize: dynamicStore.pageSize,
            parentid: routeData.value.fatherObj
              ? JSON.parse(decodeURIComponent(routeData.value.fatherObj as any)).Record_ID
              : undefined
          })
          .then((res: any) => {
            tableSetting.loading = false;
            dynamicStore.setTableData(res.List);
            dynamicStore.setSourthTableData(res.List);
            if (tableSetting.selectData.length > 0) {
              tableSetting.selectData.forEach(element => {
                if (dynamicStore.tableData.filter(s => s.Record_ID === element.Record_ID).length > 0) {
                  dynamicStore.tableData.filter(s => s.Record_ID === element.Record_ID)[0].checkbox = true;
                }
              });
            }
          });
      } else {
        getPageData();
      }
    };
    /**
     * @description 主表按钮点击事件
     * @param
     * @param
     * @returns
     */
    const buttonClick = (name: string) => {
      new ButtonClick().ParentClickEvent(name, proxy);
    };
    /**
     * @description 获取表头数据
     * @param
     * @param
     * @returns
     */
    const getColumns = async () => {
      await proxy.$vueAxios.get("MasterBaseFormModelTable/GetInitialize", { fmtId: routeData.value.fmtid }).then((res: any) => {
        dynamicStore.setVisibleConfig(res.List[0]);
        const str = "DDM_Enable_Display_" + routeData.value.status;
        const filterColumns = res.List[0].DDMList.filter((v: any) => v[str] === true).sort((a: any, b: any) => {
          return a.DDM_Order - b.DDM_Order;
        });
        tableSetting.columns = filterColumns;
      });
    };
    /**
     * @description 获取当前数据下的子级
     * @param
     * @param
     * @returns
     */
    const getChild = () => {
      proxy.$vueAxios
        .get(
          "MasterPermission/GetUserPermissionFMT",
          {
            fmId: routeData.value.fmid,
            status: routeData.value.status
          },
          {
            noLoading: true
          }
        )
        .then((res: any) => {
          FMTData.value = res.List;
          childData.value = res.List.filter((v: any) => v.FMT_Enable && v.FMT_Parent_ID === routeData.value.fmtid);
          dynamicStore.setChildData(childData.value);
        });
    };
    /**
     * @description 获取子级页面按钮权限
     * @param
     * @param
     * @returns
     */
    const getChildBtnPermission = () => {
      const filterData = catalogStore.catalogList.filter((v: any) => v.Catalog_ID === catalogStore.treeNode.Catalog_ID)[0];
      filterData ? buttonStatus.filterButtonAuth(JSON.parse(filterData.PC_PermissionStr)[0]) : buttonStatus.filterButtonAuth([]);
    };
    /**
     * @description 获取搜索功能分类数据
     * @param
     * @param
     * @returns
     */
    const getCatalog = () => {
      proxy.$vueAxios
        .get("MasterPermission/GetUserPermissionCatalog", {
          fmtId: route.query.fmtid,
          status: route.query.status
        })
        .then((res: any) => {
          catalogList.value = res.List;
        });
    };
    // 下一页
    const pageNext = () => {
      if (tableSetting.canClickNext) {
        tableSetting.canClickNext = false;
        tableSetting.loading = true;
        dynamicStore
          .getTableData({
            fmid: routeData.value.fmid,
            fmtid: routeData.value.fmtid,
            catalogid: dynamicStore.noCatalogStatus ? undefined : catalogStore.treeNode.Catalog_ID,
            status: routeData.value.status,
            searchType: 1,
            pageIndex: dynamicStore.pageIndex,
            pageSize: dynamicStore.pageSize
          })
          .then((res: any) => {
            tableSetting.loading = false;
            dynamicStore.setPageIndex();
            if (res.Count <= dynamicStore.pageIndex * dynamicStore.pageSize || res.List.length === 0) {
              dynamicStore.setPageIndex(true); //重置pageIndex为2
            }
            tableSetting.canClickNext = true;
            const data = dynamicStore.tableData;
            const datas = data.concat(res.List);
            if (res.Count <= datas.length) {
              dynamicStore.setIsShowPage(false);
            }
            dynamicStore.setTableData(datas);
          });
      }
    };
    // 全部数据
    const pageAll = () => {
      if (tableSetting.canClickNext) {
        tableSetting.canClickNext = false;
        tableSetting.loading = true;
        dynamicStore
          .getTableData({
            fmid: routeData.value.fmid,
            fmtid: routeData.value.fmtid,
            catalogid: dynamicStore.noCatalogStatus ? undefined : catalogStore.treeNode.Catalog_ID,
            status: routeData.value.status,
            searchType: 1
          })
          .then((res: any) => {
            tableSetting.canClickNext = true;
            dynamicStore.setTableData(res.List);
            tableSetting.loading = false;
          });
      }
    };
    // excel导入文件
    const exportExcel = async (files: any) => {
      await new ButtonClick().ExportExcel(files, proxy);
    };
    // 批量挂接全文配置参数
    const fulltextUploadMany = () => {
      uploadZip.value.click();
      uploadConfig.value.visible = false;
    };
    // 批量挂接全文触发事件
    const uploadZipFile = async () => {
      await new ButtonClick().uploadZipEvent(uploadZip.value.files, proxy);
      uploadZip.value.value = null;
    };
    // 页面初始化
    const init = async () => {
      // leftTree.value.getTreeData();
      dynamicStore.setChildLeftClick(false);
      getCatalog();
      await getColumns();
      dynamicStore.setFatherObj(fatherObj);
      self.value = proxy;
      getChild();
      getSearchField();
      if (fatherObj) {
        topBarShow.value = true;
        const el = document.querySelector(".vxe-grid--toolbar-wrapper") as any;
        const buttonaArr = JSON.parse(catalogStore.treeNode.PC_PermissionStr)[0];
        if (buttonaArr.length > 0) {
          if (globalStore.assemblySize === "default") {
            el.style.height = "47px";
          } else if (globalStore.assemblySize === "large") {
            el.style.height = "57px";
          } else if (globalStore.assemblySize === "small") {
            el.style.height = "37px";
          }
        } else {
          el.style.height = "0";
        }
        getChildBtnPermission();
      }
      getPageData();
    };
    onActivated(async () => {
      init();
      dynamicStore.setChildLeftClick(false);
      // dynamicStore.childTableData = [];
      if (tableSetting.rowClickObj && childData.value.length > 0) {
        await getChildButtonPermission();
        await getChildTableData();
      }

      if (leftTreeObj.value) {
        buttonStatus.filterButtonAuth(JSON.parse(leftTreeObj.value.PC_PermissionStr)[0]);
        // dynamicStore.setChildLeftClick(true);
      } else {
        // dynamicStore.setChildLeftClick(false);
      }
    });
    onDeactivated(() => {
      if (fatherObj) {
        leftTreeObj.value = null;
        console.log(leftTree.value.ztreeObj);
        console.log(leftTree.value);

        dynamicStore.setChildLeftClick(false);
        leftTree.value.clearTreeNodeSelect();
      }

      dynamicStore.tableData = [];
      dynamicStore.childTableData = [];
    });
    /**
     * @description 获取子表数据
     * @param
     * @param
     * @returns
     */
    // tab页切换事件
    const tabChange = async (val: any) => {
      console.log(val);

      if (tableSetting.rowClickObj) {
        activeName.value = val;
        // 改变按钮状态
        await getChildButtonPermission();
        await getChildTableData();
      } else {
        childTabbarRef.value[activeName.value].reloadData([]);
      }
    };
    // 获取子级表格数据
    const getChildTableData = async () => {
      if (globalStore.showChild && childData.value.length > 0) {
        childTableSetting.childLoading = true;
        try {
          // 获取子表表头数据

          const childColumnsRes = await proxy.$vueAxios.get(
            "MasterBaseFormModelTable/GetInitialize",
            {
              fmtId: childData.value[activeName.value] ? childData.value[activeName.value].FMT_ID : null
            },
            { noLoading: true }
          );
          if (childColumnsRes.Mark) {
            dynamicStore.setChildVisibleConfig(childColumnsRes.List[0]);
            const str = "DDM_Enable_Display_" + routeData.value.status;
            const filterColumns = childColumnsRes.List[0].DDMList.filter((v: any) => v[str] === true).sort((a: any, b: any) => {
              return a.DDM_Order - b.DDM_Order;
            });
            childTableSetting.childColumns = filterColumns;
          }
          // 获取子表数据
          const childTableRes = await proxy.$vueAxios.get(
            "Dynamic/CommonChildTableGet",
            {
              fmid: tableSetting.rowClickObj.FM_ID,
              dataId: tableSetting.rowClickObj.Record_ID,
              fmtType: childData.value[activeName.value].FMT_Type
            },
            { noLoading: true }
          );
          if (childTableRes.Mark) {
            childTableSetting.childTableData = childTableRes.List;
            childTableSetting.childLoading = false;
            dynamicStore.setChildTableData(childTableRes.List);
            dynamicStore.setChildSourthTableData(childTableRes.List);
          }
          await getChildDataByChildTable();
          getChildReportData();
        } catch (error) {
          childTableSetting.childLoading = false;
        } finally {
          childTableSetting.childLoading = false;
        }
      }
    };

    // 子表单击
    const childRowClick = ({ row }: any) => {
      childTabbarRef.value[activeName.value].setCheckboxRow([row], true);
      childTableSetting.rowClickObj = row;
      childTableSelect([row]);
    };
    // 子表双击
    const childRowdblClick = ({ row }: any) => {
      // 判断是否可双击打开弹框
      if (!userStore.userInfo.U_ReadOnly && childBottonList.value.includes("修改") && ![11, 21].includes(row.Status)) {
        new ButtonClick().ChildClickEvent("修改", proxy);
      }
    };
    // 子表多选
    const childTableSelect = (val: any[]) => {
      childTableSetting.selectData = val;
      dynamicStore.setChildTableSelect(val);
    };
    // 获取子表报表数据
    const getChildReportData = () => {
      proxy.$vueAxios
        .post(
          "Master_Base_ReportModule/GetConditional",
          {
            order: "RM_Index asc",
            dtoList: [{ fieldName: "FMT_ID", fieldValue: childData.value[activeName.value].FMT_ID }]
          },
          { noLoading: true }
        )
        .then((res: any) => {
          if (res.Mark) {
            childReportData.value = res.List.filter((v: any) => v.RM_Enabled);
          }
        });
    };
    /**
     * @description 获取子级表格中的按钮权限
     * @param
     * @param
     * @returns
     */
    const getChildButtonPermission = async () => {
      await proxy.$vueAxios
        .get(
          "MasterPermission/GetArchivesChildButtonPermission",
          {
            fmtId: childData.value[activeName.value].FMT_ID,
            status: routeData.value.status,
            catalogId: tableSetting.rowClickObj.Catalog_ID
          },
          {
            noLoading: true
          }
        )
        .then((res: any) => {
          const el = document.querySelectorAll(".vxe-grid--toolbar-wrapper") as any;
          if (res.Model) {
            childBottonList.value = JSON.parse(res.Model)[0];
            buttonStatus.filterChildButtonAuth(JSON.parse(res.Model)[0]);
            const buttonaArr = JSON.parse(res.Model)[0];
            if (buttonaArr.length > 0) {
              if (globalStore.assemblySize === "default") {
                el[Number(activeName.value) + 1].style.height = "47px";
              } else if (globalStore.assemblySize === "large") {
                el[Number(activeName.value) + 1].style.height = "57px";
              } else if (globalStore.assemblySize === "small") {
                el[Number(activeName.value) + 1].style.height = "37px";
              }
            } else {
              el[Number(activeName.value) + 1].style.height = "0";
            }
            if (buttonaArr.includes("导入")) {
              childTableSetting.toolbarConfig.import = {
                icon: "vxe-icon-cloud-upload"
              };
            } else {
              childTableSetting.toolbarConfig.import = false;
            }
            if (buttonaArr.includes("导出")) {
              childTableSetting.toolbarConfig.export = {
                icon: "vxe-icon-cloud-download"
              };
            } else {
              childTableSetting.toolbarConfig.export = false;
            }
            if (buttonaArr.includes("打印")) {
              childTableSetting.toolbarConfig.print = {
                icon: "vxe-icon-print"
              };
            } else {
              childTableSetting.toolbarConfig.print = false;
            }
            if (buttonaArr.includes("刷新")) {
              childTableSetting.toolbarConfig.refresh = {
                icon: "vxe-icon-refresh",
                iconLoading: "vxe-icon-refresh roll"
              };
            } else {
              childTableSetting.toolbarConfig.refresh = false;
            }
            if (buttonaArr.includes("全屏")) {
              childTableSetting.toolbarConfig.zoom = {
                iconIn: "vxe-icon-fullscreen",
                iconOut: "vxe-icon-minimize"
              };
            } else {
              childTableSetting.toolbarConfig.zoom = false;
            }
            if (buttonaArr.includes("自定义列")) {
              childTableSetting.toolbarConfig.custom = {
                icon: "vxe-icon-menu"
              };
            } else {
              childTableSetting.toolbarConfig.custom = false;
            }
            childTableSetting.toolbarConfig.enabled = true;
          } else {
            if (el.style) {
              el.style.height = "0";
            }
            buttonStatus.filterChildButtonAuth([]);
          }
        });
    };
    /**
     * @description 获取当前子级表格数据下的子级
     * @param
     * @param
     * @returns
     */
    const getChildDataByChildTable = async () => {
      await proxy.$vueAxios
        .post(
          "Master_Base_FormModel_Table/GetConditional",
          {
            order: "FMT_Type ASC",
            dtoList: [
              {
                fieldName: "FM_ID",
                fieldValue: routeData.value.fmid
              }
            ]
          },
          {
            noLoading: true
          }
        )
        .then((res: any) => {
          childTableSetting.childDataByChildTable = res.List.filter(
            (v: any) => v.FMT_Parent_ID === childData.value[activeName.value].FMT_ID
          );
        });
    };
    // 子表跳转子级页面
    const childToSublevel = async (row: any, item: any) => {
      const Res = await proxy.$vueAxios.post("Master_Base_FormModel_Table/GetConditional", {
        order: "FMT_Type ASC",
        dtoList: [
          {
            fieldName: "FM_ID",
            fieldValue: routeData.value.fmid
          }
        ]
      });
      const childrenFmtId2 = Res.List.filter((v: any) => v.FMT_Parent_ID === row.FMT_ID).map((v: any) => v.FMT_ID);
      // const stateName: any = {
      //   1: "Collect",
      //   2: "Arrangement",
      //   3: "Storage",
      //   4: "Utilization"
      // };
      router.push({
        name: "sublevel",
        query: {
          fmid: row.FM_ID,
          fmtid: item.FMT_ID,
          childrenFmtId: childrenFmtId2,
          status: routeData.value.status,
          fondsId: routeData.value.fondsId,
          code: row.Code,
          fatherObj: encodeURIComponent(JSON.stringify(row))
        }
      });
    };
    // 子表查看全文
    const childViewFullText = (row: any) => {
      drawerSetting.title = "全文管理";
      drawerSetting.visible = true;
      nextTick(() => {
        console.log(fulltextRef.value);

        fulltextRef.value.getData(row);
      });
      buttonStatus.filterFulltextButtonAuth(JSON.parse(catalogStore.treeNode.PC_PermissionStr)[1]);
    };
    // 子级表格按钮点击事件
    const childButtonClick = (name: string) => {
      new ButtonClick().ChildClickEvent(name, proxy);
    };
    // 子级表格报表导出
    const childReportExcel = (item: any) => {
      if (childTableSetting.selectData.length == 0) {
        proxy.$message.warning("请选择数据");
        return;
      }
      if (item.RM_IsFront) {
        new Excel(item, childTableSetting.selectData, [tableSetting.rowClickObj], []).download();
      } else {
        new ButtonClick().reportModuleClickEvent(item.RM_ID, item, "file");
      }
    };
    // 离线挂接提交按钮
    const mountHandle = () => {
      const { tableSelect, childTableSelect } = dynamicStore;
      mountForm.value.validate(async (valid: boolean) => {
        if (valid) {
          const errorList: any = [];
          if (mountConfig.type === "folder") {
            mountSetting.visible = false;
            for (let i = 0; i < tableSelect.length; i++) {
              proxy.$showLoading({ tip: `正在挂载第${i + 1}条数据,档号为${tableSelect[i].Code}` });
              const param = {
                path: formData.path,
                isCover: formData.isCover,
                isOrder: formData.isOrder,
                fmT_ID: tableSelect[0].FMT_ID,
                fM_ID: tableSelect[0].FM_ID,
                idList: [tableSelect[i].Record_ID]
              };
              const Res = await proxy.$vueAxios.post("MasterBaseAllInfos/MatchingAllInfo", param, { noLoading: true });
              if (!Res.Mark) {
                errorList.push([Res.Msg]);
              }
            }
            proxy.$hideLoading();
          } else if (mountConfig.type === "file") {
            mountSetting.visible = false;
            for (let i = 0; i < childTableSelect.length; i++) {
              proxy.$showLoading({ tip: `正在挂载第${i + 1}条数据,档号为${childTableSelect[i].Code}` });
              const param = {
                path: formData.path,
                isCover: formData.isCover,
                fmT_ID: childTableSelect[0].FMT_ID,
                fM_ID: childTableSelect[0].FM_ID,
                idList: [childTableSelect[i].Record_ID]
              };
              const Res = await proxy.$vueAxios.post("MasterBaseAllInfos/MatchingAllInfo", param, { noLoading: true });
              if (!Res.Mark) {
                errorList.push([Res.Msg]);
              }
            }
            proxy.$hideLoading();
          }
          if (errorList.length > 0) {
            import("@/vendor/Export2Excel").then(excel => {
              excel.export_json_to_excel({
                // 要求转出的表头是中文
                header: ["错误信息"], // 表头 必填
                data: errorList, // //具体数据 必填
                filename: "离线挂载错误信息", // 非必填
                autoWidth: true, // 非必填
                bookType: "xlsx" // 非必填
              });
            });
          }
        }
      });
    };
    // 粘贴剪切弹框确认事件
    const pasteHandle = async () => {
      const { visibleConfig, childVisibleConfig, copyData, copyChildData } = dynamicStore;

      const stateNum: any = {
        Collect: 1,
        Arrangement: 2,
        Storage: 3,
        Utilization: 4
      };
      const errList = [];
      try {
        if (pasteSetting.type === "folder") {
          for (let i = 0; i < copyData.length; i++) {
            proxy.$showLoading({ tip: `正在复制第${i + 1}条数据,档号为${copyData[i].Code}` });
            const param = {
              fromFMID: copyData[i].FM_ID,
              fromFMTID: copyData[i].FMT_ID,
              fromTableID: copyData[i].Record_ID,
              fromCatalogID: copyData[i].Catalog_ID,
              toFMID: visibleConfig.FMT.FM_ID,
              toFMTID: visibleConfig.FMT.FMT_ID,
              fromFondsID: copyData[i].Fonds_ID,
              toFondsID: catalogStore.treeNode.Fonds_ID,
              toStatus: stateNum[routeData.value.status],
              toParentID: dynamicStore.childLeftClick ? 0 : fatherObj ? fatherObj.Record_ID : 0,
              toCatalog_ID: catalogStore.treeNode.Catalog_ID ? catalogStore.treeNode.Catalog_ID : null,
              is_Copy: pasteSetting.is_Copy,
              is_CopyJN: true,
              is_CopyAllInfo: pasteFormData.isTrue
            };
            const Res = await proxy.$vueAxios.post("Dynamic/MovePaste", param, { noLoading: true });
            if (!Res.Mark) {
              errList.push(Res.Msg);
            }
          }
          if (dynamicStore.noCatalogStatus) {
            noClassManage();
          } else {
            getPageData();
          }
        } else if (pasteSetting.type === "file") {
          for (let i = 0; i < copyChildData.length; i++) {
            proxy.$showLoading({ tip: `正在复制第${i + 1}条数据,档号为${copyChildData[i].Code}` });
            const param = {
              fromFMID: copyChildData[i].FM_ID,
              fromFMTID: copyChildData[i].FMT_ID,
              fromTableID: copyChildData[i].Record_ID,
              fromCatalogID: copyChildData[i].Catalog_ID,
              toFMID: childVisibleConfig.FMT.FM_ID,
              toFMTID: childVisibleConfig.FMT.FMT_ID,
              fromFondsID: copyChildData[i].Fonds_ID,
              toFondsID: catalogStore.treeNode.Fonds_ID,
              toStatus: stateNum[routeData.value.status],
              toParentID: tableSetting.rowClickObj.Record_ID,
              toCatalog_ID: catalogStore.treeNode.Catalog_ID,
              is_Copy: pasteSetting.is_Copy,
              is_CopyJN: true,
              is_CopyAllInfo: pasteFormData.isTrue
            };
            const Res = await proxy.$vueAxios.post("Dynamic/MovePaste", param, { noLoading: true });
            if (!Res.Mark) {
              errList.push(Res.Msg);
            }
          }
          getChildTableData();
        }
        if (errList.length > 0) {
          pasteSetting.visible = false;
          proxy.$message.error("操作失败");
        } else {
          pasteSetting.visible = false;
          proxy.$message.success("操作成功");
        }
        proxy.$hideLoading();
      } catch (error) {
        pasteSetting.visible = false;
        proxy.$message.error("操作失败");
        proxy.$hideLoading();
        getPageData();
      }
    };
    // 中止请求
    const cease = () => {
      singalrModal.discontinueStatus = !singalrModal.discontinueStatus;
      singalrModal.networkStatus = !singalrModal.networkStatus;
      if (singalrModal.discontinueStatus) {
        singalrModal.discontinueFont = "恢复";
      } else {
        singalrModal.discontinueFont = "中止";
      }
      new ButtonClick().ParentClickEvent("删除", proxy);
    };
    // 取消请求
    const cancel = () => {
      singalrModal.circulatingIndex = 0;
      singalrModal.percent = 0;
      singalrModal.visible = false;
      singalrModal.discontinueStatus = false;
      singalrModal.networkStatus = true;
      singalrModal.discontinueFont = "中止";
      singalrModal.AllNetworkStatus = false;
    };
    // 流水号移至确认事件
    const LSHMoveHandle = () => {
      if (LSHMoveSetting.type === "folder") {
        proxy.$vueAxios
          .post("Dynamic/MoveOrder", {
            tableName: dynamicStore.visibleConfig.FMT.FMT_TableName,
            fM_ID: dynamicStore.tableSelect[0].FM_ID,
            fmT_ID: dynamicStore.tableSelect[0].FMT_ID,
            catalog_ID: dynamicStore.tableSelect[0].Catalog_ID,
            record_ID: dynamicStore.tableSelect[0].Record_ID,
            moveOrder: LSHMoveFormData.value.moveOrder,
            isOrder: true,
            fonds_ID: dynamicStore.tableSelect[0].Fonds_ID
          })
          .then((res: any) => {
            if (res.Mark) {
              LSHMoveSetting.visible = false;
              dynamicStore.updateTableData(res.List[0]);
            }
          });
      } else {
        proxy.$vueAxios
          .post("Dynamic/MoveOrder", {
            tableName: dynamicStore.visibleConfig.FMT.FMT_TableName,
            fM_ID: dynamicStore.childTableSelect[0].FM_ID,
            fmT_ID: dynamicStore.childTableSelect[0].FMT_ID,
            catalog_ID: dynamicStore.childTableSelect[0].Catalog_ID,
            record_ID: dynamicStore.childTableSelect[0].Record_ID,
            moveOrder: LSHMoveFormData.value.moveOrder,
            isOrder: false,
            fonds_ID: dynamicStore.childTableSelect[0].Fonds_ID
          })
          .then((res: any) => {
            if (res.Mark) {
              LSHMoveSetting.visible = false;
              dynamicStore.childTableSelect(res.List[0]);
            }
          });
      }
    };
    // 标记备注勾选框改变事件
    const remarkChange = (val: boolean) => {
      if (val) {
        remarkFormData.color = "";
        remarkFormData.content = "";
      }
    };
    // 标记备注确认事件
    const remarkHandle = () => {
      remarkForm.value.validate((valid: boolean) => {
        if (valid) {
          if (remarkSetting.type === "folder") {
            proxy.$vueAxios
              .post("Dynamic/ChangeMark", {
                fmT_ID: dynamicStore.tableSelect[0].FMT_ID,
                ids: dynamicStore.tableSelect.map((v: any) => v.Record_ID),
                markColor: remarkFormData.color,
                markContent: remarkFormData.content
              })
              .then((res: any) => {
                if (res.Mark) {
                  dynamicStore.tableSelect.forEach(item => {
                    item.MarkColor = remarkFormData.color;
                    item.MarkContent = remarkFormData.content;
                  });
                  proxy.$message.success("操作成功");
                  remarkSetting.visible = false;
                } else {
                  remarkSetting.visible = false;
                  proxy.$message.error("操作失败");
                }
              });
          } else {
            proxy.$vueAxios
              .post("Dynamic/ChangeMark", {
                fmT_ID: dynamicStore.childTableSelect[0].FMT_ID,
                ids: dynamicStore.childTableSelect.map((v: any) => v.Record_ID),
                markColor: remarkFormData.color,
                markContent: remarkFormData.content
              })
              .then((res: any) => {
                if (res.Mark) {
                  dynamicStore.childTableSelect.forEach(item => {
                    item.MarkColor = remarkFormData.color;
                    item.MarkContent = remarkFormData.content;
                  });
                  proxy.$message.success("操作成功");
                  remarkSetting.visible = false;
                } else {
                  remarkSetting.visible = false;
                  proxy.$message.error("操作失败");
                }
              });
          }
        }
      });
    };
    // 数据查重确认事件
    const dataCheckHandle = () => {
      const stateNum: any = {
        Collect: 1,
        Arrangement: 2,
        Storage: 3,
        Utilization: 4
      };
      dataCheckForm.value.validate((valid: boolean) => {
        if (valid) {
          if (dataCheckSetting.type === "folder") {
            proxy.$vueAxios
              .get("Dynamic/DistinctGet", {
                fmid: routeData.value.fmid,
                fmtid: routeData.value.fmtid,
                status: stateNum[routeData.value.status],
                groupby: dataCheckFormData.field.join(",")
              })
              .then((res: any) => {
                if (res.Mark) {
                  proxy.$message.success("操作成功");
                  dynamicStore.setTableData(res.List);
                } else {
                  proxy.$message.error("操作失败");
                }
                dataCheckSetting.visible = false;
              });
          } else {
            proxy.$vueAxios
              .get("Dynamic/DistinctGet", {
                fmid: dynamicStore.childTableData[0].FM_ID,
                fmtid: dynamicStore.childTableData[0].FMT_ID,
                groupby: dataCheckFormData.field.join(",")
              })
              .then((res: any) => {
                if (res.Mark) {
                  proxy.$message.success("操作成功");
                  dynamicStore.setChildTableData(res.List);
                } else {
                  proxy.$message.error("操作失败");
                }
                dataCheckSetting.visible = false;
              });
          }
        }
      });
    };
    // 重置流水号
    const resetLSHHandle = async () => {
      const { tableSelect, visibleConfig } = dynamicStore;
      for (let i = 0; i < tableSelect.length; i++) {
        delete tableSelect[i].checkbox;
        const modalFormData = { ...tableSelect[i], Order: resetLSHFormData.lsh_start + i };
        const FieldRuleClass = new RuleClass({
          modalFormData: modalFormData,
          ruleList: visibleConfig.FieldRule.filter((v: any) => v.FR_Enable === true),
          tableName: visibleConfig.FMT.FMT_TableName
        }); // 执行字段规则类方法
        FieldRuleClass.fieldRuleEvent2();
        await proxy.$vueAxios
          .put(
            "Dynamic",
            {
              list: [{ ...modalFormData }],
              tableName: visibleConfig.FMT.FMT_TableName
            },
            { noLoading: true }
          )
          .then((res: any) => {
            if (res.Mark) {
              dynamicStore.updateTableData(res.List[0]);
            }
          });
      }
      resetLSH.visible = false;
    };

    // 四性检测抽屉展示操作
    const showFourAspectRecords = (row: any) => {
      console.log("拿到当前行数据----", row);
      fourAspectRecordsClickRow.value = row;
      isShowFourAspectRecords.value = true;
    };

    // 显示主表元数据弹框
    const showFolderMetaData = (row: any) => {
      metaDataSetting.visible = true;
      nextTick(() => {
        metaDataRef.value.activeName = "1";
        metaDataRef.value.record = row;
        metaDataRef.value.getTableData1(row);
      });
    };
    const showFileMetaData = (row: any) => {
      metaDataSetting.visible = true;
      nextTick(() => {
        metaDataRef.value.activeName = "1";
        metaDataRef.value.record = row;
        metaDataRef.value.getTableData1(row);
      });
    };
    // 拆卷确认
    const dismantleHandle = async () => {
      const { tableSelect, visibleConfig, childTableSelect, childVisibleConfig } = dynamicStore;
      if (dismantleSetting.type === "folder") {
        for (let i = 0; i < tableSelect.length; i++) {
          delete tableSelect[i].checkbox;
          const modalFormData = {
            ...tableSelect[i],
            Parent_ID: null,
            Catalog_ID: dismantleSetting.isTrue ? null : tableSelect[i].Catalog_ID,
            Code: null
          };
          await proxy.$vueAxios
            .put(
              "Dynamic",
              {
                list: [{ ...modalFormData }],
                tableName: visibleConfig.FMT.FMT_TableName
              },
              { noLoading: true }
            )
            .then((res: any) => {
              if (res.Mark) {
                dynamicStore.updateTableData(res.List[0]);
              }
            });
          if (dismantleSetting.isTrue) {
            const index2 = dynamicStore.tableData.findIndex((v: any) => v.Record_ID === tableSelect[i].Record_ID);
            if (index2 > -1) {
              dynamicStore.tableData.splice(index2, 1);
            }
          }
        }
      } else {
        for (let i = 0; i < childTableSelect.length; i++) {
          delete childTableSelect[i].checkbox;
          const modalFormData = {
            ...childTableSelect[i],
            Parent_ID: null,
            Catalog_ID: dismantleSetting.isTrue ? null : childTableSelect[i].Catalog_ID,
            Code: null
          };
          await proxy.$vueAxios
            .put(
              "Dynamic",
              {
                list: [{ ...modalFormData }],
                tableName: childVisibleConfig.FMT.FMT_TableName
              },
              { noLoading: true }
            )
            .then((res: any) => {
              if (res.Mark) {
                dynamicStore.updateChildTableData(res.List[0]);
              }
            });
          const index3 = dynamicStore.childTableData.findIndex((v: any) => v.Record_ID === childTableSelect[i].Record_ID);

          if (index3 > -1) {
            dynamicStore.childTableData.splice(index3, 1);
          }
        }
      }
      dismantleSetting.visible = false;
    };
    // 查询归卷下拉框切换事件
    const queryTheVolumeSelectChange = (val: string) => {
      proxy.$vueAxios
        .get(
          "MasterBaseFormModelTable/GetInitialize",
          {
            fmtId: val
          },
          { noLoading: true }
        )
        .then((res: any) => {
          console.log(res.List[0]);
          queryTheVolumeRule.value = res.List[0];
        });
    };
    // 查询归卷表格选中事件
    const queryTheVolumeTableSelect = (val: any[]) => {
      queryTheVolumeTableSetting.selectData = val;
    };
    // 查询归卷左侧树点击事件
    const onQueryTheVolumeTreeClick = (treeNode: any) => {
      const stateName: any = {
        1: "Collect",
        2: "Arrangement",
        3: "Storage",
        4: "Utilization"
      };
      const params = {
        fmid: tableSetting.rowClickObj.FM_ID,
        fmtid: queryTheVolumeSelect.value,
        catalogid: treeNode.Catalog_ID,
        status: routeData.value.status,
        searchType: 3,
        pageIndex: 1,
        pageSize: 3000,
        parentid: null
      };
      proxy.$vueAxios.get("Dynamic/CommonGet", params, { noLoading: true }).then((res: any) => {
        queryTheVolumeTableSetting.data = res.List;
        queryTheVolumeTableSetting.sourceData = res.List;
      });
    };
    //查询归卷点击无分类
    const noQueryTheVolumeTreeClassMana = () => {
      const stateName: any = {
        1: "Collect",
        2: "Arrangement",
        3: "Storage",
        4: "Utilization"
      };
      const params = {
        fmid: tableSetting.rowClickObj.FM_ID,
        fmtid: queryTheVolumeSelect.value,
        status: routeData.value.status,
        searchType: leftTreeObj.value ? 1 : 2,
        pageIndex: 1,
        pageSize: 3000,
        parentid: null
      };
      proxy.$vueAxios.get("Dynamic/CommonGet", params, { noLoading: true }).then((res: any) => {
        queryTheVolumeTableSetting.data = res.List;
        queryTheVolumeTableSetting.sourceData = res.List;
      });
    };
    // 查询归卷确认
    const queryTheVolumeHandle = async () => {
      const tableName = FMTData.value.filter((v: any) => v.FMT_ID === queryTheVolumeSelect.value)[0].FMT_TableName;
      for (let i = 0; i < queryTheVolumeTableSetting.selectData.length; i++) {
        const item = {
          ...queryTheVolumeTableSetting.selectData[i],
          Catalog_ID: tableSetting.rowClickObj.Catalog_ID,
          Parent_ID: tableSetting.rowClickObj.Record_ID
        };
        delete item.checkbox;
        delete item._X_ROW_KEY;
        const FieldRuleClass = new RuleClass({
          modalFormData: item,
          ruleList: queryTheVolumeRule.value.FieldRule.filter((v: any) => v.FR_Enable === true),
          tableName: tableName
        }); // 执行字段规则类方法
        await FieldRuleClass.fieldRuleEvent2();
        console.log(item);

        await proxy.$vueAxios
          .put(
            "Dynamic",
            {
              list: [{ ...item }],
              tableName: tableName
            },
            { noLoading: true }
          )
          .then((res: any) => {
            if (res.Mark) {
              const index = queryTheVolumeTableSetting.data.findIndex((v: any) => v.Record_ID === item.Record_ID);
              if (index > -1) {
                queryTheVolumeTableSetting.data.splice(index, 1);
              }
            }
          });
      }
    };
    // 查询归卷搜索功能
    const queryTheVolumeInputChange = () => {
      console.log(queryTheVolumeInput.value);
      queryTheVolumeTableSetting.data = queryTheVolumeTableSetting.sourceData.filter((v: any) => {
        return ACrypto.getSS(v.Title).includes(queryTheVolumeInput.value);
      });
    };
    // 重置流水号
    const resetLSHEvent = async () => {
      let order = LSHSetting.startLSH;
      LSHSetting.loading = true;
      LSHSetting.btnLoading = true;
      for (let i = 0; i < LSHSetting.data.length; i++) {
        LSHSetting.loadingText = `正在加载第${i + 1}条数据...`;
        const item = cloneDeep(LSHSetting.data[i]);
        delete item.checkbox;
        delete item.ROWINDEX;
        let modalFormData = {};
        if (LSHSetting.orderType === "Order") {
          modalFormData = { ...item, Order: order++ };
        } else {
          modalFormData = { ...item, SmallOrder: order++ };
          // LSHSetting.orderType
        }
        const FieldRuleClass = new RuleClass({
          modalFormData: modalFormData,
          ruleList: LSHSetting.ruleList,
          tableName: LSHSetting.tableName,
          isMax: false
        }); // 执行字段规则类方法
        FieldRuleClass.fieldRuleEvent2();
        const res = await proxy.$vueAxios.put(
          "Dynamic",
          {
            list: [{ ...modalFormData, _X_ROW_KEY: undefined }],
            tableName: LSHSetting.tableName
          },
          { noLoading: true }
        );
        if (res.Mark) {
          LSHSetting.data[i][LSHSetting.orderType] = res.List[0][LSHSetting.orderType];
          LSHSetting.data[i].Code = res.List[0].Code;
          // dynamicStore.updateTableData(res.List[0]);
        }
      }
      LSHSetting.loading = false;
      LSHSetting.btnLoading = false;
    };
    // 流水号表格点击事件
    const LSHRowClick = ({ row, rowIndex }: any) => {
      LSHSetting.rowClickObj = row;
      LSHSetting.LShTableIndex = rowIndex;
      console.log(LSHSetting.LShTableIndex);
    };
    // 流水号上移
    const sortUpLSH = async (index: number) => {
      if (index <= 0) {
        proxy.$message.warning("已经是第一条了");
        return;
      }
      LSHSetting.loading = true;
      LSHSetting.loadingText = `正在上移...`;
      LSHSetting.btnLoading2 = true;
      const newData = cloneDeep(LSHSetting.data);
      let temp = newData[index - 1];
      let tempOrder = newData[index - 1][LSHSetting.orderType];
      newData[index - 1][LSHSetting.orderType] = newData[index][LSHSetting.orderType];
      newData[index][LSHSetting.orderType] = tempOrder;
      newData.splice(index - 1, 1);
      newData.splice(index, 0, temp);
      const FieldRuleClass = new RuleClass({
        modalFormData: newData[index],
        ruleList: LSHSetting.ruleList,
        tableName: LSHSetting.tableName,
        isMax: false
      });
      // 执行字段规则类方法
      FieldRuleClass.fieldRuleEvent2();
      const FieldRuleClass2 = new RuleClass({
        modalFormData: newData[index - 1],
        ruleList: LSHSetting.ruleList,
        tableName: LSHSetting.tableName,
        isMax: false
      });
      // 执行字段规则类方法
      FieldRuleClass2.fieldRuleEvent2();
      await proxy.$vueAxios.put(
        "Dynamic",
        {
          list: [{ ...newData[index], _X_ROW_KEY: undefined }],
          tableName: LSHSetting.tableName
        },
        { noLoading: true }
      );
      await proxy.$vueAxios.put(
        "Dynamic",
        {
          list: [{ ...newData[index - 1], _X_ROW_KEY: undefined }],
          tableName: LSHSetting.tableName
        },
        { noLoading: true }
      );
      LSHSetting.data = newData;
      if (LSHSetting.LShTableIndex > 0) {
        LSHSetting.LShTableIndex -= 1;
      }
      LSHSetting.loading = false;
      LSHSetting.btnLoading2 = false;
    };
    // 流水号下移
    const sortDownLSH = async (index: number) => {
      console.log(LSHSetting.ruleList, LSHSetting.tableName);

      if (index >= LSHSetting.data.length - 1) {
        proxy.$message.warning("已经是最后一条了");
        return;
      }
      LSHSetting.loading = true;
      LSHSetting.loadingText = `正在下移...`;
      LSHSetting.btnLoading3 = true;
      const newData = cloneDeep(LSHSetting.data);
      const temp = newData[index + 1];
      const tempOrder = newData[index + 1][LSHSetting.orderType];
      newData[index + 1][LSHSetting.orderType] = newData[index][LSHSetting.orderType];
      newData[index][LSHSetting.orderType] = tempOrder;
      newData.splice(index + 1, 1);
      newData.splice(index, 0, temp);

      const FieldRuleClass = new RuleClass({
        modalFormData: newData[index],
        ruleList: LSHSetting.ruleList,
        tableName: LSHSetting.tableName,
        isMax: false
      });
      // 执行字段规则类方法
      FieldRuleClass.fieldRuleEvent2();
      const FieldRuleClass2 = new RuleClass({
        modalFormData: newData[index + 1],
        ruleList: LSHSetting.ruleList,
        tableName: LSHSetting.tableName,
        isMax: false
      });
      // 执行字段规则类方法
      FieldRuleClass2.fieldRuleEvent2();
      const res = await proxy.$vueAxios.put(
        "Dynamic",
        {
          list: [{ ...newData[index], _X_ROW_KEY: undefined }],
          tableName: LSHSetting.tableName
        },
        { noLoading: true }
      );
      const res2 = await proxy.$vueAxios.put(
        "Dynamic",
        {
          list: [{ ...newData[index + 1], _X_ROW_KEY: undefined }],
          tableName: LSHSetting.tableName
        },
        { noLoading: true }
      );
      LSHSetting.data = newData;
      if (LSHSetting.LShTableIndex < LSHSetting.data.length - 1) {
        LSHSetting.LShTableIndex += 1;
      }
      LSHSetting.loading = false;
      LSHSetting.btnLoading3 = false;
    };
    // 流水号移至
    const LSHTo = async () => {
      if (LSHSetting.endLSH <= 0) {
        proxy.$message.warning("流水号不能小于1");
      } else if (LSHSetting.endLSH == LSHSetting.LShTableIndex + 1) {
        proxy.$message.warning("流水号不能移至相同位置");
      } else if (LSHSetting.endLSH > LSHSetting.data.length) {
        proxy.$message.warning("流水号不能超出总行数");
      }
      LSHSetting.loading = true;
      LSHSetting.loadingText = `正在移至流水...`;
      LSHSetting.btnLoading4 = true;
      // 深拷贝数据源
      const newData = cloneDeep(LSHSetting.data);
      // 要移至的目标对象order
      const tempOrder = newData[LSHSetting.endLSH - 1][LSHSetting.orderType];
      // 将当前选中的数据order改为要移至的目标对象order
      newData[LSHSetting.LShTableIndex][LSHSetting.orderType] = tempOrder;
      // 获取当前选中的数据
      const element = newData[LSHSetting.LShTableIndex];
      // 获取删除选中数据之后的数组
      newData.splice(LSHSetting.LShTableIndex, 1);
      // 将选中元素插入到要移至元素原来的位置
      newData.splice(LSHSetting.endLSH - 1, 0, element);

      // 执行字段规则
      const FieldRuleClass = new RuleClass({
        modalFormData: element,
        ruleList: LSHSetting.ruleList,
        tableName: LSHSetting.tableName,
        isMax: false
      });
      // 执行字段规则类方法
      FieldRuleClass.fieldRuleEvent2();
      // 修改数据到数据库
      await proxy.$vueAxios.put(
        "Dynamic",
        {
          list: [{ ...element, _X_ROW_KEY: undefined }],
          tableName: LSHSetting.tableName
        },
        { noLoading: true }
      );
      if (LSHSetting.LShTableIndex > LSHSetting.endLSH - 1) {
        for (let i = LSHSetting.LShTableIndex; LSHSetting.endLSH - 1 < i; i--) {
          const item = newData[i];
          item[LSHSetting.orderType] = parseInt(item[LSHSetting.orderType]) + 1;
          // 执行字段规则
          const FieldRuleClass = new RuleClass({
            modalFormData: item,
            ruleList: LSHSetting.ruleList,
            tableName: LSHSetting.tableName,
            isMax: false
          });
          // 执行字段规则类方法
          FieldRuleClass.fieldRuleEvent2();
          // 修改数据到数据库
          const res = await proxy.$vueAxios.put(
            "Dynamic",
            {
              list: [{ ...item, _X_ROW_KEY: undefined }],
              tableName: LSHSetting.tableName
            },
            { noLoading: true }
          );
        }
      } else {
        for (let i = LSHSetting.LShTableIndex; i < LSHSetting.endLSH - 1; i++) {
          const item = newData[i];
          item[LSHSetting.orderType] = parseInt(item[LSHSetting.orderType]) - 1;
          // 执行字段规则
          const FieldRuleClass = new RuleClass({
            modalFormData: item,
            ruleList: LSHSetting.ruleList,
            tableName: LSHSetting.tableName,
            isMax: false
          });
          // 执行字段规则类方法
          FieldRuleClass.fieldRuleEvent2();
          // 修改数据到数据库
          const res = await proxy.$vueAxios.put(
            "Dynamic",
            {
              list: [{ ...item, _X_ROW_KEY: undefined }],
              tableName: LSHSetting.tableName
            },
            { noLoading: true }
          );
        }
      }
      LSHSetting.data = newData;
      LSHSetting.loading = false;
      LSHSetting.btnLoading4 = false;
      LSHSetting.LShTableIndex = LSHSetting.endLSH - 1;
    };
    // 流水操作确认事件
    const LSHandle = () => {
      LSHSetting.visible = false;

      if (LSHSetting.type === 1) {
        getPageData();
      } else if (LSHSetting.type === 2) {
        getChildTableData();
      }
    };
    // 搜索弹框确认事件
    const searchHandle = () => {
      searchSetting.visible = false;
    };
    // 点击回收站按钮
    const recycle = () => {
      headerHeight.value = 42;
      const el = document.querySelector(".vxe-grid--toolbar-wrapper") as any;
      if (globalStore.assemblySize === "default") {
        el.style.height = "47px";
      } else if (globalStore.assemblySize === "large") {
        el.style.height = "57px";
      } else if (globalStore.assemblySize === "small") {
        el.style.height = "37px";
      }
      recycleStatus.value = true;
      topBarShow.value = false;
      tableSetting.loading = true;
      recycleBtnStatus.value = [true, true];
      dynamicStore.childTableData = [];
      dynamicStore
        .getTableData({
          fmid: routeData.value.fmid,
          fmtid: routeData.value.fmtid,
          status: routeData.value.status,
          searchType: 10,
          pageIndex: 1,
          pageSize: dynamicStore.pageSize,
          parentid: routeData.value.fatherObj
            ? JSON.parse(decodeURIComponent(routeData.value.fatherObj as any)).Record_ID
            : undefined,
          isDelete: true
        })
        .then((res: any) => {
          tableSetting.loading = false;
          dynamicStore.setTableData(res.List);
          dynamicStore.setSourthTableData(res.List);
        });
    };
    // 还原
    const restore = async () => {
      for (let i = 0; i < dynamicStore.tableSelect.length; i++) {
        console.log(i);
        const item = dynamicStore.tableSelect[i];
        console.log("1111111111111111111111111111111", item);

        const Res = await proxy.$vueAxios.put(
          "Dynamic",
          {
            list: [{ Record_ID: item.Record_ID, FMT_ID: item.FMT_ID, FM_ID: item.FM_ID, IsDelete: false }],
            tableName: dynamicStore.visibleConfig.FMT.FMT_TableName
          },
          { noLoading: true }
        );
        if (Res.Mark) {
          // dynamicStore.delTableSelectData(
          //   dynamicStore.tableSelect.splice(
          //     dynamicStore.tableSelect.findIndex((v: any) => v.Record_ID === item.Record_ID),
          //     1
          //   )
          // );
          dynamicStore.tableData.splice(
            dynamicStore.tableData.findIndex((v: any) => v.Record_ID === item.Record_ID),
            1
          );
        }
      }
      dynamicStore.tableSelect = [];
      dynamicStore.childTableData = [];
      recycleBtnStatus.value = [true, true];
    };
    // 删除回收站
    const recycleDel = async () => {
      for (let i = 0; i < dynamicStore.tableSelect.length; i++) {
        const item = dynamicStore.tableSelect[i];
        const Res = await proxy.$vueAxios.delete2(
          "Dynamic",
          {
            list: [{ Record_ID: item.Record_ID, FMT_ID: item.FMT_ID, FM_ID: item.FM_ID }],
            tableName: dynamicStore.visibleConfig.FMT.FMT_TableName
          },
          { noLoading: true }
        );
        if (Res.Mark) {
          // dynamicStore.delTableSelectData(
          //   dynamicStore.tableSelect.splice(
          //     dynamicStore.tableSelect.findIndex((v: any) => v.Record_ID === item.Record_ID),
          //     1
          //   )
          // );
          dynamicStore.tableData.splice(
            dynamicStore.tableData.findIndex((v: any) => v.Record_ID === item.Record_ID),
            1
          );
        }
      }
      dynamicStore.tableSelect = [];
      dynamicStore.childTableData = [];
      recycleBtnStatus.value = [true, true];
    };
    // url借阅点击确认
    const urlBorrow = () => {
      urlModal.isShow = false;
      proxy.$message.success("借阅成功");
    };
    // 表格刷新
    const tableRefresh = () => {
      let catalogId = null;
      let type = 1;
      if (fatherObj) {
        if (dynamicStore.childLeftClick) {
          catalogId = leftTreeObj.value.Catalog_ID;
          type = 1;
        } else {
          if (!dynamicStore.noCatalogStatus) {
            type = 2;
          } else {
            catalogId = null;
            type = 1;
          }
        }
      } else {
        if (!dynamicStore.noCatalogStatus) {
          catalogId = leftTreeObj.value.Catalog_ID;
          type = 1;
        } else {
          catalogId = null;
          type = 1;
        }
      }
      dynamicStore
        .getTableData({
          fmid: routeData.value.fmid,
          fmtid: routeData.value.fmtid,
          catalogid: catalogId,
          status: routeData.value.status,
          searchType: type,
          pageIndex: 1,
          pageSize: dynamicStore.pageSize,
          parentid: routeData.value.fatherObj
            ? JSON.parse(decodeURIComponent(routeData.value.fatherObj as any)).Record_ID
            : undefined
        })
        .then((res: any) => {
          tableSetting.loading = false;
          dynamicStore.setTableData(res.List);
          dynamicStore.setSourthTableData(res.List);
          if (tableSetting.selectData.length > 0) {
            tableSetting.selectData.forEach(element => {
              if (dynamicStore.tableData.filter(s => s.Record_ID === element.Record_ID).length > 0) {
                dynamicStore.tableData.filter(s => s.Record_ID === element.Record_ID)[0].checkbox = true;
              }
            });
          }
        });
    };
    // 检测主表格数据变化
    watch(
      () => [...dynamicStore.tableData],
      (newValue, oldValue) => {
        if (tabbarRef.value && tabbarRef.value !== "undefined") {
          tabbarRef.value.reloadData(newValue);
        }
      }
    );
    // 检测子级表格数据变化
    watch(
      () => [...dynamicStore.childTableData],
      (newValue, oldValue) => {
        nextTick(() => {
          if (childTabbarRef.value) {
            childTabbarRef.value[activeName.value].reloadData(newValue);
          }
        });
      }
    );
    // 检测路由变化
    watch(
      () => route.query,
      (newVal, oldVal) => {
        routeData.value = newVal;
      },
      { deep: true }
    );
    // 监听组件尺寸
    watch(
      () => globalStore.assemblySize,
      (newVal, oldVal) => {
        const el = document.querySelectorAll(".vxe-grid--toolbar-wrapper") as any;
        if (globalStore.assemblySize === "default") {
          el[0].style.height = "47px";
          el[Number(activeName.value) + 1].style.height = "47px";
        } else if (globalStore.assemblySize === "large") {
          el[0].style.height = "57px";
          el[Number(activeName.value) + 1].style.height = "57px";
        } else if (globalStore.assemblySize === "small") {
          el[0].style.height = "37px";
          el[Number(activeName.value) + 1].style.height = "37px";
        }
      }
    );
    onMounted(() => {
      signalrEvent();
      init();
    });
    return {
      activatedFlag,
      catalogList,
      topBarShow,
      tableHeight,
      headerHeight,
      sumHeight,
      dynamicStore,
      formModel,
      searchFieldData,
      formRef,
      tableSearch,
      route,
      tabbarRef,
      routeData,
      fatherObj,
      dynamicModal,
      self,
      fulltextRef,
      metaDataRef,
      tableSetting,
      drawerSetting,
      childData,
      leftTreeObj,
      QRCode1,
      QRCode2,
      SortModalRef,
      dictionary,
      handoverSetting,
      HandOverModalRef,
      uploadZip,
      uploadConfig,
      fulltextModal,
      childTableSetting,
      globalStore,
      childTabbarRef,
      activeName,
      leftTree,
      reportData,
      childReportData,
      TrailRef,
      TrailConfig,
      FMTData,
      fourAspectShow,
      isShowFourAspectRecords,
      fourAspectConfigs,
      fourAspectRow,
      fourAspectRecordsClickRow,
      fourAspectRef,
      curFourAspectItem,
      allFinish,
      activeIndex,
      AuthConfig,
      mountSetting,
      formData,
      mountForm,
      mountRule,
      mountConfig,
      pasteSetting,
      pasteFormData,
      childHeight,
      childHeaderHeight,
      childTableHeight,
      singalrModal,
      remarkSetting,
      remarkFormData,
      remarkForm,
      dataCheckSetting,
      dataCheckFormData,
      dataCheckForm,
      dataCheckRule,
      ReplacementConfig,
      LSHMoveSetting,
      LSHMoveFormData,
      replaceModal,
      resetLSH,
      resetLSHFormData,
      LHSRule,
      resetLHSRef,
      metaDataSetting,
      dismantleSetting,
      queryTheVolumeSetting,
      queryTheVolumeSelect,
      queryTheVolumeTableSetting,
      queryTheVolumeInput,
      queryTheVolumeRule,
      tableIndex,
      LSHSetting,
      lshTable,
      childBottonList,
      searchSetting,
      recycleStatus,
      urlModal,
      UrlBorrowRef,
      appStore,
      recycleBtnStatus,
      //函数
      getPageData,
      search,
      reset,
      getSearchField,
      trigger,
      init,
      onTreeClick,
      signalrEvent,
      rowClick,
      rowdblClick,
      getColumns,
      tableSelect,
      toSublevel,
      viewFullText,
      buttonClick,
      getChild,
      pageNext,
      pageAll,
      transTree,
      getChildBtnPermission,
      getCatalog,
      exportExcel,
      uploadZipFile,
      fulltextUploadMany,
      childRowClick,
      childRowdblClick,
      childTableSelect,
      childViewFullText,
      childToSublevel,
      childButtonClick,
      tabChange,
      reportExcel,
      childReportExcel,
      getChildReportData,
      menuClick,
      seletedDataHandle,
      stopCheckHandle,
      mountHandle,
      pasteHandle,
      cease,
      cancel,
      remarkHandle,
      remarkChange,
      dataCheckHandle,
      LSHMoveHandle,
      noClassManage,
      resetLSHHandle,
      showFolderMetaData,
      showFourAspectRecords,
      getChildTableData,
      showFileMetaData,
      dismantleHandle,
      queryTheVolumeHandle,
      onQueryTheVolumeTreeClick,
      queryTheVolumeSelectChange,
      queryTheVolumeTableSelect,
      queryTheVolumeInputChange,
      noQueryTheVolumeTreeClassMana,
      resetLSHEvent,
      sortUpLSH,
      sortDownLSH,
      LSHTo,
      LSHandle,
      LSHRowClick,
      searchHandle,
      recycle,
      restore,
      recycleDel,
      urlBorrow,
      getFullTextData,
      tableRefresh
    };
  }
});
</script>

<style scoped lang="scss">
.main-box {
  .tree {
    height: 100%;

    // width: 260px;
    padding: 0;

    // margin-right: 10px;
    overflow: auto !important;

    /* stylelint-disable-next-line selector-id-pattern */
    :deep(#treeDemo) {
      display: flex !important;
    }
  }
  .table-box {
    width: 100%;
    .table-search {
      min-height: 110px;
      padding: 5px;
    }
    :deep(.el-tabs__content) {
      height: 100%;
    }
    :deep(.el-tabs__header) {
      margin: 0;
      background: #ffffff;
      .el-tabs__item {
        padding-left: 15px;
      }
    }
    .tableWraper {
      position: relative;
    }
    .showIcon {
      position: absolute;
      top: 52px;
      right: 8px;
      z-index: 1001;
    }
  }
}
.btns {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.queryTheVolume_dialog {
  :deep(.el-dialog) {
    height: 80%;
    .el-dialog__body {
      height: calc(100% - 134px);
    }
  }
  .queryTheVolume_content {
    display: flex;
    gap: 15px;
    justify-content: space-between;
    height: calc(100% - 30px);
    .queryTheVolume_content_left {
      width: 300px;
      overflow: auto;
    }
    .queryTheVolume_content_right {
      flex: 1;
    }
  }
}
:deep(.vxe-grid--toolbar-wrapper) {
  height: 0;
}
:deep(.header-button-lf) {
  display: flex;
}
.pasteModal {
  :deep(.el-dialog__body) {
    height: 80px;
  }
}
</style>
